home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Apple II / System 6.0 Sample Code / FinderXDA / FinderXDA.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-15  |  84.4 KB  |  2,623 lines  |  [TEXT/MPS ]

  1. /********************************************************************
  2. *    FinderXDA                                                        *
  3. *    Written by Bob Haven based on TestDA written By John Selhorst    *
  4. *********************************************************************/
  5.  
  6.  
  7. #include <memory.h>
  8. #include <GSOS.h>
  9. #include <loader.h>
  10. #include <setjmp.h>
  11. #include <stdio.h>
  12. #include <misctool.h>
  13. #include <locator.h>
  14. #include <finder.h>
  15. #include <resources.h>
  16. #include <IntMath.h>
  17. #include <quickdraw.h>
  18. #include <menu.h>
  19. #include <window.h>
  20. #include <desk.h>
  21. #include <strings.h>
  22. #include <TextEdit.h>
  23. #include <font.h>
  24.  
  25. #include "rDefs.h"    
  26.  
  27.  
  28. /************************************************************************************************/
  29.  
  30. extern void AsmProc();
  31. extern char beginDA[];
  32.  
  33. extern int _toolErr;
  34.  
  35. /* Here's the controls for the main window */
  36.  
  37. extern StaticTextTemplate     PathnameStatText;
  38. extern TextEditTemplate        PathnameTextEdit;
  39. extern PopupTemplate         AcceptRequestsPopUp;
  40. extern PopupTemplate         SendRequestsPopUp;
  41. extern PopupTemplate         tellFinderMItemSelectedPopUp;
  42. extern MenuItemTemplate     tellFinderAddToExtrasMenuItem;
  43. extern CheckBoxTemplate     HiliteBitCheckBox;
  44. extern CheckBoxTemplate     HandleItFlagCheckBox;
  45. extern CheckBoxTemplate     DeselectIconsCheckBox;
  46. extern CheckBoxTemplate        ExtendedIconsCheckBox;
  47. extern StaticTextTemplate     ColorValueStatText;
  48. extern TextEditTemplate     ColorValueTextEdit;
  49. extern SimpleButtonTemplate SetIconColorButton;
  50. extern SimpleButtonTemplate helpButton;
  51. extern TextEditTemplate     MyWindCtl;
  52.  
  53. /* Here's the controls for the tellFInderMatchFileToIcon window */
  54.  
  55. extern SimpleButtonTemplate    MatchButton;
  56. extern StaticTextTemplate    VotingBitsStatText;
  57. extern TextEditTemplate        VotingBitsTextEdit;
  58. extern StaticTextTemplate    MatchWhichStatText;
  59. extern TextEditTemplate        MatchWhichTextEdit;
  60. extern StaticTextTemplate    FileTypeStatText;
  61. extern TextEditTemplate     FileTypeTextEdit;
  62. extern StaticTextTemplate    AuxTypeStatText;
  63. extern TextEditTemplate        AuxTypeTextEdit;
  64. extern StaticTextTemplate    FilenameStatText;    
  65. extern TextEditTemplate        FilenameTextEdit;
  66. extern StaticTextTemplate    CreateDateStatText;
  67. extern TextEditTemplate        CreateDateTextEdit;
  68. extern StaticTextTemplate    ModDateStatText;
  69. extern TextEditTemplate        ModDateTextEdit;
  70. extern StaticTextTemplate    AccessStatText;
  71. extern TextEditTemplate        AccessTextEdit;
  72. extern StaticTextTemplate    FlagsStatText;
  73. extern TextEditTemplate        FlagsTextEdit;
  74. extern StaticTextTemplate    EOFStatText;
  75. extern TextEditTemplate        EOFTextEdit;
  76.  
  77. /************************************************************************************************/
  78.  
  79. /* Most of the Globals are here */
  80.  
  81. static word myID;
  82. static word NDA_ID;
  83.  
  84. static unsigned int FinderMemoryID;
  85.  
  86. static Boolean FMStarted = 0;
  87. static Boolean TEStarted = 0;
  88.  
  89. static Handle FMZeroPageHndl;
  90. static Handle TEZeroPageHndl;
  91.  
  92. char finderTarget[] = NAME_OF_FINDER;
  93.  
  94. int OpenFlag = 0;                                                /* flag to indicate if the main window is open */
  95. int quitflag = 0;                                                 /* set to 1 by action routine if its time to quit */
  96.  
  97. int finderSaysIdleFlag = 0;                                        /* used to limit the number of finderSaysIdle requests */
  98. Rect IdleRect;    
  99.  
  100. NDASysWindRecord FinderXDANDASysWindRec;
  101.  
  102. NDASysWindRecord DebugInfoNDASysWindRec;
  103. NDASysWindRecord GetSelectedIconsNDASysWindRec;
  104. NDASysWindRecord GetWindowIconsNDASysWindRec;
  105. NDASysWindRecord HelpNDASysWindRec;
  106. NDASysWindRecord MatchNDASysWindRec;
  107.  
  108. AuxWindInfoPtr DebugInfoAuxWindRecPtr;
  109. AuxWindInfoPtr GetSelectedIconsAuxWindRecPtr;
  110. AuxWindInfoPtr GetWindowIconsAuxWindRecPtr;
  111. AuxWindInfoPtr HelpAuxWindRecPtr;
  112. AuxWindInfoPtr MatchAuxWindRecPtr;
  113.  
  114. GrafPortPtr FinderXDAWindPtr = 0;                                /* Window pointer for DA window */
  115. GrafPortPtr DebugInfoWindPtr = 0;                                /* Window pointer for tellFinderGetDebugInfo window */
  116. GrafPortPtr GetSelectedIconsWindPtr = 0;                        /* Window pointer for tellFinderGetSelectedIcons window */
  117. GrafPortPtr GetWindowIconsWindPtr = 0;                            /* Window pointer for tellFinderGetWindowIcons window */
  118. GrafPortPtr HelpWindPtr = 0;                                    /* Window pointer for Help window */
  119. GrafPortPtr MatchWindPtr = 0;                                    /* Window pointer for tellFinderMatchFileToIcons window */
  120.  
  121. CtlRecHndl HelpCtlHandle;         
  122. CtlRecHndl MatchCtlHandle;
  123.  
  124. tellFinderGetSelectedIconsOut tellFinderGetSelectedIconsOutput;    /* this is global because I pass him to tellFinderSetSelectedIconsProc */
  125.  
  126. static char AlertString[400];                                    /* used for all AlertWindow calls */
  127. static char ErrorString[128];                                    /* is passed back from my generic error checking routine */
  128.  
  129. #define         MAXNUMMENUITEMS  16                                /* Constant for the max num of menuitems allowed by this tool */
  130. static word        menuItemID[MAXNUMMENUITEMS];                    /* Global array to hold ID's of added/deleted menu items */
  131. int             menuItemIndex = 0;                                /* Array index to pass to add and delete procs */
  132.  
  133. /************************************************************************************************/
  134.  
  135. /* A control update proc used by all the windows */
  136.  
  137. static void UpdateControls()
  138.     {
  139.         DrawControls(GetPort());
  140.     }
  141.  
  142. /* Control list for the main window */
  143.  
  144. static Pointer FinderXDACtlList[] =    {
  145.                                     (Pointer)&helpButton,
  146.                                     (Pointer)&SetIconColorButton,
  147.                                     (Pointer)&ColorValueStatText,    
  148.                                     (Pointer)&HandleItFlagCheckBox,
  149.                                     (Pointer)&HiliteBitCheckBox,
  150.                                     (Pointer)&DeselectIconsCheckBox,
  151.                                     (Pointer)&ExtendedIconsCheckBox,
  152.                                     (Pointer)&tellFinderMItemSelectedPopUp,
  153.                                     (Pointer)&SendRequestsPopUp,
  154.                                     (Pointer)&AcceptRequestsPopUp,
  155.                                     (Pointer)&PathnameTextEdit,
  156.                                     (Pointer)&ColorValueTextEdit,
  157.                                     (Pointer)&PathnameStatText,
  158.                                     NULL
  159.                                     };
  160.  
  161. /************************************************************************************************/
  162. /* Main window wind parmam list and color table (color table used by other windows */
  163.  
  164. WindColor WindowColorTable[5] = { 0x0000,0x0f10,0x001e,0x4004,0x0000 };
  165.  
  166. static ParamList FinderXDAWindParams = {
  167.                                         sizeof(FinderXDAWindParams),
  168.                                         0xc2a8,
  169.                                         "\pFinderXDA",
  170.                                         NULL,
  171.                                         0,0,0,0,
  172.                                         WindowColorTable,
  173.                                         0,0,
  174.                                         200,640,
  175.                                         200,640,
  176.                                         4,16,
  177.                                         40,160,
  178.                                         0L,
  179.                                         0,
  180.                                         NULL,
  181.                                         NULL,
  182.                                         UpdateControls,
  183.                                         25,96,187,546,
  184.                                         (GrafPortPtr) -1L,
  185.                                         NULL};
  186.  
  187. /************************************************************************************************/
  188. /* Param list for the tellFinderGetDebugInfo window */
  189.  
  190. static ParamList DebugInfoWindParams = {
  191.                                         sizeof(DebugInfoWindParams),
  192.                                         0xc2a8,
  193.                                         "\ptellFinderGetDebugInfo Window",
  194.                                         NULL,
  195.                                         0,0,0,0,
  196.                                         WindowColorTable,        /* We use the DA window color table */
  197.                                         0,0,
  198.                                         200,640,
  199.                                         200,640,
  200.                                         4,16,
  201.                                         40,160,
  202.                                         0L,
  203.                                         0,
  204.                                         NULL,
  205.                                         NULL,
  206.                                         UpdateControls,
  207.                                         25,40,182,600,
  208.                                         (GrafPortPtr) -1L,
  209.                                         NULL};
  210.  
  211. /************************************************************************************************/
  212. /* Param list for the tellFinderGetSelectedIcons window */
  213.  
  214. static ParamList GetSelectedIconsWindParams =    {
  215.                                                 sizeof(GetSelectedIconsWindParams),
  216.                                                 0xc2a8,
  217.                                                 "\ptellFinderGetSelectedIcons Pathnames Window",
  218.                                                 NULL,
  219.                                                 0,0,0,0,
  220.                                                 WindowColorTable,
  221.                                                 0,0,
  222.                                                 200,640,
  223.                                                 200,640,
  224.                                                 4,16,
  225.                                                 40,160,
  226.                                                 0L,
  227.                                                 0,
  228.                                                 NULL,
  229.                                                 NULL,
  230.                                                 UpdateControls,
  231.                                                 25,40,182,600,
  232.                                                 (GrafPortPtr) -1L,
  233.                                                 NULL};
  234.  
  235. /************************************************************************************************/
  236. /* Param list for the tellFinderGetWindowIcons window */
  237.  
  238. static ParamList GetWindowIconsWindParams = {
  239.                                             sizeof(GetWindowIconsWindParams),
  240.                                             0xc2a8,
  241.                                             "\ptellFinderGetWindowIcons Pathnames Window",
  242.                                             NULL,
  243.                                             0,0,0,0,
  244.                                             WindowColorTable,
  245.                                             0,0,
  246.                                             200,640,
  247.                                             200,640,
  248.                                             4,16,
  249.                                             40,160,
  250.                                             0L,
  251.                                             0,
  252.                                             NULL,
  253.                                             NULL,
  254.                                             UpdateControls,
  255.                                             25,40,182,600,
  256.                                             (GrafPortPtr) -1L,
  257.                                             NULL};
  258.  
  259. /************************************************************************************************/
  260. /* Param list for the Help window */
  261.  
  262. static ParamList HelpWindParams = {
  263.                                         sizeof(HelpWindParams),
  264.                                         0xc2a8,
  265.                                         "\pHelp Window",
  266.                                         NULL,
  267.                                         0,0,0,0,
  268.                                         WindowColorTable,        /* We use the DA window color table */
  269.                                         0,0,
  270.                                         200,640,
  271.                                         200,640,
  272.                                         4,16,
  273.                                         40,160,
  274.                                         0L,
  275.                                         0,
  276.                                         NULL,
  277.                                         NULL,
  278.                                         UpdateControls,
  279.                                         25,40,182,600,
  280.                                         (GrafPortPtr) -1L,
  281.                                         NULL};
  282.  
  283. /************************************************************************************************/
  284. /* Param list and control list for the tellFinderMatchFileToIcon window */
  285.  
  286. static Pointer MatchCtlList[] =    {
  287.                                 (Pointer)&MatchButton,
  288.                                 (Pointer)&EOFTextEdit,
  289.                                 (Pointer)&EOFStatText,
  290.                                 (Pointer)&FlagsTextEdit,
  291.                                 (Pointer)&FlagsStatText,
  292.                                 (Pointer)&AccessTextEdit,
  293.                                 (Pointer)&AccessStatText,
  294.                                 (Pointer)&ModDateTextEdit,
  295.                                 (Pointer)&ModDateStatText,
  296.                                 (Pointer)&CreateDateTextEdit,
  297.                                 (Pointer)&CreateDateStatText,
  298.                                 (Pointer)&FilenameTextEdit,
  299.                                 (Pointer)&FilenameStatText,    
  300.                                 (Pointer)&AuxTypeTextEdit,
  301.                                 (Pointer)&AuxTypeStatText,
  302.                                 (Pointer)&FileTypeTextEdit,
  303.                                 (Pointer)&FileTypeStatText,
  304.                                 (Pointer)&MatchWhichTextEdit,
  305.                                 (Pointer)&MatchWhichStatText,
  306.                                 (Pointer)&VotingBitsTextEdit,
  307.                                 (Pointer)&VotingBitsStatText,
  308.                                 NULL
  309.                                 };
  310.  
  311. static ParamList MatchWindParams = {
  312.                                     sizeof(MatchWindParams),
  313.                                     0xc2a8,
  314.                                     "\ptellFinderMatchFileToIcons Window",
  315.                                     NULL,
  316.                                     0,0,0,0,
  317.                                     WindowColorTable,
  318.                                     0,0,
  319.                                     200,640,
  320.                                     200,640,
  321.                                     4,16,
  322.                                     40,160,
  323.                                     0L,
  324.                                     0,
  325.                                     NULL,
  326.                                     NULL,
  327.                                     UpdateControls,
  328.                                     25,40,190,600,
  329.                                     (GrafPortPtr) -1L,
  330.                                     NULL};
  331.  
  332. /************************************************************************************************/
  333. /* Here's a routine I use to find the next visible window and return the windowptr to the caller */
  334.  
  335. GrafPortPtr findNextVisWindow()
  336. {
  337.     GrafPortPtr whichWindow = FrontWindow();
  338.     
  339.     while (whichWindow != NIL)
  340.     {
  341.         whichWindow = GetNextWindow(whichWindow);
  342.         if(whichWindow == NIL) break;
  343.         if (GetSysWFlag(whichWindow)) continue;
  344.         if(GetWFrame (whichWindow) & fVis) break;
  345.     }
  346.     return whichWindow;
  347. }
  348.  
  349. /************************************************************************************************/
  350.  
  351. pascal void CloseFinderXDA();        /* Predeclared for use by the following functions */
  352.  
  353. /* A bunch of functions to setup data structs required when creating windows from your DA */
  354.  
  355. SetUpDebugInfoNDASysWindRec()
  356. {
  357.     DebugInfoNDASysWindRec.status = 0;
  358.     DebugInfoNDASysWindRec.openProc = 0;
  359.     DebugInfoNDASysWindRec.closeProc = (ProcPtr)CloseFinderXDA;
  360.     DebugInfoNDASysWindRec.actionProc = (ProcPtr)AsmProc;
  361.     DebugInfoNDASysWindRec.initProc = 0;
  362.     DebugInfoNDASysWindRec.period = 0;
  363.     DebugInfoNDASysWindRec.eventMask = everyEvent;
  364.     DebugInfoNDASysWindRec.lastServiced = 0;
  365.     DebugInfoNDASysWindRec.windowPtr = 0;
  366.     DebugInfoNDASysWindRec.ndaHandle = 0;
  367.     DebugInfoNDASysWindRec.memoryID = myID;
  368. }
  369.  
  370. SetUpGetSelectedIconsNDASysWindRec()
  371. {
  372.     GetSelectedIconsNDASysWindRec.status = 0;
  373.     GetSelectedIconsNDASysWindRec.openProc = 0;
  374.     GetSelectedIconsNDASysWindRec.closeProc = (ProcPtr)CloseFinderXDA;
  375.     GetSelectedIconsNDASysWindRec.actionProc = (ProcPtr)AsmProc;
  376.     GetSelectedIconsNDASysWindRec.initProc = 0;
  377.     GetSelectedIconsNDASysWindRec.period = 0;
  378.     GetSelectedIconsNDASysWindRec.eventMask = everyEvent;
  379.     GetSelectedIconsNDASysWindRec.lastServiced = 0;
  380.     GetSelectedIconsNDASysWindRec.windowPtr = 0;
  381.     GetSelectedIconsNDASysWindRec.ndaHandle = 0;
  382.     GetSelectedIconsNDASysWindRec.memoryID = myID;
  383. }
  384.  
  385. SetUpGetWindowIconsNDASysWindRec()
  386. {
  387.     GetWindowIconsNDASysWindRec.status = 0;
  388.     GetWindowIconsNDASysWindRec.openProc = 0;
  389.     GetWindowIconsNDASysWindRec.closeProc = (ProcPtr)CloseFinderXDA;
  390.     GetWindowIconsNDASysWindRec.actionProc = (ProcPtr)AsmProc;
  391.     GetWindowIconsNDASysWindRec.initProc = 0;
  392.     GetWindowIconsNDASysWindRec.period = 0;
  393.     GetWindowIconsNDASysWindRec.eventMask = everyEvent;
  394.     GetWindowIconsNDASysWindRec.lastServiced = 0;
  395.     GetWindowIconsNDASysWindRec.windowPtr = 0;
  396.     GetWindowIconsNDASysWindRec.ndaHandle = 0;
  397.     GetWindowIconsNDASysWindRec.memoryID = myID;
  398. }
  399.  
  400. SetUpHelpNDASysWindRec()
  401. {
  402.     HelpNDASysWindRec.status = 0;
  403.     HelpNDASysWindRec.openProc = 0;
  404.     HelpNDASysWindRec.closeProc = (ProcPtr)CloseFinderXDA;
  405.     HelpNDASysWindRec.actionProc = (ProcPtr)AsmProc;
  406.     HelpNDASysWindRec.initProc = 0;
  407.     HelpNDASysWindRec.period = 0;
  408.     HelpNDASysWindRec.eventMask = everyEvent;
  409.     HelpNDASysWindRec.lastServiced = 0;
  410.     HelpNDASysWindRec.windowPtr = 0;
  411.     HelpNDASysWindRec.ndaHandle = 0;
  412.     HelpNDASysWindRec.memoryID = myID;
  413. }
  414.  
  415. SetUpMatchNDASysWindRec()
  416. {
  417.     MatchNDASysWindRec.status = 0;
  418.     MatchNDASysWindRec.openProc = 0;
  419.     MatchNDASysWindRec.closeProc = (ProcPtr)CloseFinderXDA;
  420.     MatchNDASysWindRec.actionProc = (ProcPtr)AsmProc;
  421.     MatchNDASysWindRec.initProc = 0;
  422.     MatchNDASysWindRec.period = 0;
  423.     MatchNDASysWindRec.eventMask = everyEvent;
  424.     MatchNDASysWindRec.lastServiced = 0;
  425.     MatchNDASysWindRec.windowPtr = 0;
  426.     MatchNDASysWindRec.ndaHandle = 0;
  427.     MatchNDASysWindRec.memoryID = myID;
  428. }
  429.  
  430. /************************************************************************************************/
  431. /* This is my generic error checking routine. It takes the _toolErr and Display flag as input params. */
  432. /* It converts the _toolErr number into a string which is a global. The string is displayed in an */\
  433. /* AlertWindow depending on the value of the flag param. */
  434.  
  435. CheckError(ErrorNum,DisplayFlag)
  436. word ErrorNum;
  437. word DisplayFlag;                            /* 1 = Display AlertWindow, != 1 don't show, and return ErrorString */
  438. {        
  439.     strcpy (ErrorString,"Unknown error");     /* Initialize error string if we don't know the error number */
  440.     switch(ErrorNum)
  441.         {
  442.             case 0x0000:
  443.             strcpy(ErrorString,"No error");
  444.             break;
  445.             
  446.             
  447.             /* Finder errors */
  448.             
  449.             case 0x4201:
  450.             strcpy(ErrorString,"Finder - bad input value");
  451.             break;
  452.             
  453.             case 0x4202:
  454.             strcpy(ErrorString,"Finder - could not complete request");
  455.             break;
  456.             
  457.             case 0x4203:
  458.             strcpy(ErrorString,"Finder - user cancelled operation");
  459.             break;
  460.             
  461.             case 0x4204:
  462.             strcpy(ErrorString,"Finder - menu item was dimmed");
  463.             break;
  464.             
  465.             case 0x4205:
  466.             strcpy(ErrorString,"Finder - not now, Finder has a headache");
  467.             break;
  468.             
  469.             case 0x4206:
  470.             strcpy(ErrorString,"Finder - can't add Finder's resources to desktop file");
  471.             break;
  472.             
  473.             case 0x4207:
  474.             strcpy(ErrorString,"Finder - unknown rBundle version, or rBundle damaged");
  475.             break;
  476.             
  477.             case 0x42FF:
  478.             strcpy(ErrorString,"Finder - request not implemented");
  479.             break;
  480.             
  481.  
  482.             /* GS/OS errors */
  483.             
  484.             case 0x0027:
  485.             strcpy(ErrorString,"GSOS - I/O error");
  486.             break;
  487.             
  488.             case 0x0028:
  489.             strcpy(ErrorString,"GSOS - no device connected");
  490.             break;
  491.             
  492.             case 0x002E:
  493.             strcpy(ErrorString,"GSOS - disk switched");
  494.             break;
  495.             
  496.             case 0x0040:
  497.             strcpy(ErrorString,"GSOS - invalid pathname syntax");
  498.             break;
  499.             
  500.             case 0x0044:
  501.             strcpy(ErrorString,"GSOS - path not found");
  502.             break;
  503.             
  504.             case 0x0045:
  505.             strcpy(ErrorString,"GSOS - volume not found");
  506.             break;
  507.             
  508.             case 0x0046:
  509.             strcpy(ErrorString,"GSOS - file not found");
  510.             break;
  511.             
  512.             case 0x004A:
  513.             strcpy(ErrorString,"GSOS - version error");
  514.             break;
  515.             
  516.             case 0x004E:
  517.             strcpy(ErrorString,"GSOS - access not allowed");
  518.             break;
  519.             
  520.             case 0x004F:
  521.             strcpy(ErrorString,"GSOS - buffer too small");
  522.             break;
  523.             
  524.             case 0x0050:
  525.             strcpy(ErrorString,"GSOS - file open");
  526.             break;
  527.             
  528.             case 0x0052:
  529.             strcpy(ErrorString,"GSOS - unsupported volume type");
  530.             break;
  531.             
  532.             case 0x0058:
  533.             strcpy(ErrorString,"GSOS - not a block device");
  534.             break;
  535.  
  536.             case 0x0059:
  537.             strcpy(ErrorString,"GSOS - invalid file level");
  538.             break;
  539.  
  540.             case 0x005c:
  541.             strcpy(ErrorString,"GSOS - not an application");
  542.             break;
  543.  
  544.  
  545.             /* Loader Errors */
  546.             
  547.             case 0x1101:
  548.             strcpy(ErrorString,"Loader - entry not found");
  549.             break;
  550.             
  551.             case 0x1103:
  552.             strcpy(ErrorString,"Loader - pathname error");
  553.             break;
  554.             
  555.             /* Desk Manager Errors */
  556.             
  557.             case 0x0510:
  558.             strcpy(ErrorString,"Desk Manager - specified NDA not available");
  559.             break;
  560.             
  561.             case 0x0511:
  562.             strcpy(ErrorString,"Desk Manager - not pointer to a System window");
  563.             break;
  564.             
  565.             
  566.             /* Tool Locator Errors */
  567.             
  568.             case 0x0001:
  569.             strcpy(ErrorString,"Tool Locator - tool not found");
  570.             break;
  571.             
  572.             case 0x0110:
  573.             strcpy(ErrorString,"Tool Locator - tool specified minimum version not found");
  574.             break;
  575.             
  576.             
  577.             /* TextEdit Errors */
  578.             
  579.             case 0x2201:
  580.             strcpy(ErrorString,"TextEdit already started");
  581.             break;
  582.             
  583.             case 0x220D:
  584.             strcpy(ErrorString,"TextEdit - the Font Manager was not started");
  585.             break;
  586.             
  587.             case 0x2202:
  588.             strcpy(ErrorString,"TextEdit - TextEdit not started");
  589.             break;
  590.             
  591.             case 0x2203:
  592.             strcpy(ErrorString,"TextEdit - the teH parameter does not refer to a valid TERecord");
  593.             break;
  594.             
  595.             case 0x2204:
  596.             strcpy(ErrorString,"TextEdit - invalid text descriptor value specified");
  597.             break;
  598.             
  599.             case 0x2208:
  600.             strcpy(ErrorString,"TextEdit - TE buffer overflow");
  601.             break;
  602.             
  603.             case 0x220C:
  604.             strcpy(ErrorString,"TextEdit - LETextBox2 format codes were inconsistent");
  605.             break;
  606.             
  607.             /* Font Manager Errors */
  608.  
  609.             case 0x1B01:
  610.             strcpy(ErrorString,"Font Manager - duplicate FMStartUp call");
  611.             break;
  612.             
  613.             case 0x1B03:
  614.             strcpy(ErrorString,"Font Manager - Font Manager not active");
  615.             break;
  616.             
  617.             
  618.             /* Control Manager Errors */
  619.  
  620.             case 0x1004:
  621.             strcpy(ErrorString,"Control Manager - no controls in window");
  622.             break;
  623.             
  624.             case 0x1005:
  625.             strcpy(ErrorString,"Control Manager - no extended controls in window");
  626.             break;
  627.             
  628.             case 0x1009:
  629.             strcpy(ErrorString,"Control Manager - the specified control ID cannot be found");
  630.             break;
  631.             
  632.             case 0x100C:
  633.             strcpy(ErrorString,"Control Manager - no FrontWindow to make call on");
  634.             break;
  635.             
  636.             
  637.             /* Memory Manager Errors */
  638.  
  639.             case 0x0201:
  640.             strcpy(ErrorString,"Memory Manager - unable to allocate block");
  641.             break;
  642.             
  643.             case 0x0204:
  644.             strcpy(ErrorString,"Memory Manager - illegal operation on a locked or immovable block");
  645.             break;
  646.             
  647.             case 0x0206:
  648.             strcpy(ErrorString,"Memory Manager - invalid handle");
  649.             break;
  650.             
  651.             case 0x0207:
  652.             strcpy(ErrorString,"Memory Manager - invalid user ID");
  653.             break;
  654.             
  655.             
  656.             /* Integer Math errors */
  657.             
  658.             case 0x0B02:
  659.             strcpy(ErrorString,"Integer Math - illegal character in string");
  660.             break;
  661.             
  662.             case 0x0B03:
  663.             strcpy(ErrorString,"Integer Math - hex value is greater than $FFFFFFFF");
  664.             break;
  665.             
  666.             case 0x0B04:
  667.             strcpy(ErrorString,"Integer Math - string too short to represent value");
  668.             break;
  669.             
  670.             
  671.             /* Resource Manager errors */
  672.             
  673.             case 0x1E04:
  674.             strcpy(ErrorString,"Resource Manager - no current open resource files");
  675.             break;
  676.             
  677.             case 0x1E06:
  678.             strcpy(ErrorString,"Resource Manager - specified resource not found");
  679.             break;
  680.             
  681.             case 0x1E08:
  682.             strcpy(ErrorString,"Resource Manager - user ID not found");
  683.             break;
  684.  
  685.             case 0x1E09:
  686.             strcpy(ErrorString,"Resource Manager - no more resource IDs available");
  687.             break;
  688.             
  689.             case 0x1E10:
  690.             strcpy(ErrorString,"Resource Manager - no resource with geven name");
  691.             break;
  692.             
  693.             case 0x1E12:
  694.             strcpy(ErrorString,"Resource Manager - already started with this ID");
  695.             break;
  696.             
  697.             case 0x1E0B:
  698.             strcpy(ErrorString,"Resource Manager - resource file is already open");
  699.             break;
  700.         }
  701.     sprintf(AlertString,"42/Error = $%x\r%s/^OK",                /* setup the string for AlertWindow */
  702.         ErrorNum,
  703.         ErrorString);
  704.     if (DisplayFlag == 1)                                        /* call AlertWindow if flag = 1 */
  705.         {
  706.             AlertWindow (0x0000,NULL,AlertString);
  707.         }
  708. }
  709.  
  710. /************************************************************************************************/
  711. /* This is called by the DA Close Proc to close other windows opened by this DA */
  712.  
  713. void CloseIfOpen(PtrToWind)
  714.     GrafPortPtr *PtrToWind;
  715. {
  716.     if(*PtrToWind!=NIL)
  717.     {
  718.         CloseWindow(*PtrToWind);
  719.         *PtrToWind = NIL;
  720.     }
  721. }
  722.  
  723. /************************************************************************************************/
  724. /* This routine is called by the tellFinderMatchFileToIconProc. It Sets up DataIn and calls to SendReqest. */
  725.  
  726. DoTheMatchProc()
  727. {
  728.     tellFinderMatchFileToIconOut    tellFinderMatchFileToIconOutput;
  729.     tellFinderMatchFileToIconIn        tellFinderMatchFileToIconInput;
  730.     char                             votingBitsString[4];
  731.     char                             whichMatchString[4];
  732.     char                             filetypeString[4];
  733.     char                             auxtypeString[8];
  734.     ptr                                 filenameToMatchPtr;
  735.     char                             createFileInfoPtrString[8];
  736.     char                             modFileInfoPtrString[8];
  737.     char                             localAccessString[4];
  738.     char                             flagsString[4];
  739.     char                            combinedEOFString[8];
  740.     int                                errorFlag = 0;
  741.     word                            ButtonSelected;
  742.     long                            textLength;
  743.  
  744.     tellFinderMatchFileToIconInput.pCount = 11;
  745.     
  746.     /* I get the text from all the controls, convert them, and then stuff them into the DataIn struc */
  747.     /* to be passed in SendRequest. I do some error checking for right number of chars and values. The */
  748.     /* first param on TEGetText determines the format of the text. */
  749.     
  750.     if ((textLength = TEGetText (0x0005,votingBitsString,4L,0x0000,0L,GetCtlHandleFromID(NIL,0x00002002L))) < 4)
  751.         {
  752.             AlertWindow (0x0000,NULL,"32/Too few characters in votingBitsString string./^OK");
  753.             errorFlag = 1;
  754.         }
  755.     else
  756.         {
  757.             tellFinderMatchFileToIconInput.votingBits = (word)Hex2Int(votingBitsString,4);
  758.             if(_toolErr)
  759.                 {
  760.                     CheckError(_toolErr,0x0001);
  761.                     errorFlag = 1;
  762.                 }
  763.         }
  764.  
  765.     if ((textLength = TEGetText (0x0005,whichMatchString,4L,0x0000,0L,GetCtlHandleFromID(NIL,0x00002004L))) < 4)
  766.         {
  767.             AlertWindow (0x0000,NULL,"32/Too few characters in whichMatchString string./^OK");
  768.             errorFlag = 1;
  769.         }
  770.     else
  771.         {
  772.             tellFinderMatchFileToIconInput.whichMatch = (word)Hex2Long(whichMatchString,4);
  773.             if(_toolErr)
  774.                 {
  775.                     CheckError(_toolErr,0x0001);
  776.                     errorFlag = 1;
  777.                 }
  778.         }
  779.     
  780.     if ((textLength = TEGetText (0x0005,filetypeString,4L,0x0000,0L,GetCtlHandleFromID(NIL,0x00002006L))) < 4)
  781.         {
  782.             AlertWindow (0x0000,NULL,"32/Too few characters in filetypeString string./^OK");
  783.             errorFlag = 1;
  784.         }
  785.     else
  786.         {
  787.             tellFinderMatchFileToIconInput.filetype = (word)Hex2Long(filetypeString,4);
  788.             if(_toolErr)
  789.                 {
  790.                     CheckError(_toolErr,0x0001);
  791.                     errorFlag = 1;
  792.                 }
  793.         }
  794.  
  795.     if ((textLength = TEGetText (0x0005,auxtypeString,8L,0x0000,0L,GetCtlHandleFromID(NIL,0x00002008L))) < 8)
  796.         {
  797.             AlertWindow (0x0000,NULL,"32/Too few characters in auxtypeString string./^OK");
  798.             errorFlag = 1;
  799.         }
  800.     else
  801.         {
  802.             tellFinderMatchFileToIconInput.auxtype = (long)Hex2Long(auxtypeString,8);
  803.             if(_toolErr)
  804.                 {
  805.                     CheckError(_toolErr,0x0001);
  806.                     errorFlag = 1;
  807.                 }
  808.         }
  809.  
  810.     TEGetText (0x0000,filenameToMatchPtr,0x000000ffL,0x0000,0L,GetCtlHandleFromID(NIL,0x0000200AL));
  811.     if(_toolErr)
  812.         {
  813.             CheckError(_toolErr,0x0001);
  814.             errorFlag = 1;
  815.         }
  816.     else
  817.         tellFinderMatchFileToIconInput.matchFilenamePtr = filenameToMatchPtr;
  818.  
  819.     if ((textLength = TEGetText (0x0005,createFileInfoPtrString,8L,0x0000,0L,GetCtlHandleFromID(NIL,0x0000200CL))) < 8)
  820.         {
  821.             AlertWindow (0x0000,NULL,"32/Too few characters in createFileInfoPtrString string./^OK");
  822.             errorFlag = 1;
  823.         }
  824.     else
  825.         {
  826.             tellFinderMatchFileToIconInput.createFileInfoPtr = (Ptr)Hex2Long(createFileInfoPtrString,8);
  827.             if(_toolErr)
  828.                 {
  829.                     CheckError(_toolErr,0x0001);
  830.                     errorFlag = 1;
  831.                 }
  832.         }
  833.  
  834.     if ((textLength = TEGetText (0x0005,modFileInfoPtrString,8L,0x0000,0L,GetCtlHandleFromID(NIL,0x0000200EL))) < 8)
  835.         {
  836.             AlertWindow (0x0000,NULL,"32/Too few characters in modFileInfoPtrString string./^OK");
  837.             errorFlag = 1;
  838.         }
  839.     else
  840.         {
  841.             tellFinderMatchFileToIconInput.modFileInfoPtr = (Ptr)Hex2Long(modFileInfoPtrString,8);
  842.             if(_toolErr)
  843.                 {
  844.                     CheckError(_toolErr,0x0001);
  845.                     errorFlag = 1;
  846.                 }
  847.         }
  848.  
  849.     if ((textLength = TEGetText (0x0005,localAccessString,4L,0x0000,0L,GetCtlHandleFromID(NIL,0x00002010L))) < 4)
  850.         {
  851.             AlertWindow (0x0000,NULL,"32/Too few characters in localAccessString string./^OK");
  852.             errorFlag = 1;
  853.         }
  854.     else
  855.         {
  856.             tellFinderMatchFileToIconInput.localAccess = (word)Hex2Long(localAccessString,4);
  857.             if(_toolErr)
  858.                 {
  859.                     CheckError(_toolErr,0x0001);
  860.                     errorFlag = 1;
  861.                 }
  862.         }
  863.  
  864.     if ((textLength = TEGetText (0x0005,flagsString,4L,0x0000,0L,GetCtlHandleFromID(NIL,0x00002012L))) < 4)
  865.         {
  866.             AlertWindow (0x0000,NULL,"32/Too few characters in flagsString string./^OK");
  867.             errorFlag = 1;
  868.         }
  869.     else
  870.         {
  871.             tellFinderMatchFileToIconInput.flags = (word)Hex2Long(flagsString,4);
  872.             if(_toolErr)
  873.                 {
  874.                     CheckError(_toolErr,0x0001);
  875.                     errorFlag = 1;
  876.                 }
  877.         }
  878.  
  879.     tellFinderMatchFileToIconInput.optionListPtr = NIL;
  880.  
  881.     if ((textLength = TEGetText (0x0005,combinedEOFString,8L,0x0000,0L,GetCtlHandleFromID(NIL,0x00002014L))) < 8)
  882.         {
  883.             AlertWindow (0x0000,NULL,"32/Too few characters in combinedEOFString string./^OK");
  884.             errorFlag = 1;
  885.         }
  886.     else
  887.         {
  888.             tellFinderMatchFileToIconInput.combinedEOF = (long)Hex2Long(combinedEOFString,8);
  889.             if(_toolErr)
  890.                 {
  891.                     CheckError(_toolErr,0x0001);
  892.                     errorFlag = 1;
  893.                 }
  894.         }
  895.  
  896.  
  897.  
  898.     /* If I didn't get any errors from above, I call SendRequest and AlertWindow to display DataOut from SendRequest */
  899.     
  900.     if (errorFlag == 0)
  901.         {
  902.             SendRequest (tellFinderGetDebugInfo,0x8001,finderTarget,&tellFinderMatchFileToIconInput,&tellFinderMatchFileToIconOutput);
  903.             sprintf(AlertString,"90/recvCount = $%x\rfinderResult = $%x\roneDocOffset = $%lxL\rrBundleHandle = $%lxL\rsmallIconHandle = $%lxL\rlargeIconHandle = $%lxL\rrFinderPathHandle = $%lxL/^OK",
  904.                 tellFinderMatchFileToIconOutput.recvCount,
  905.                 tellFinderMatchFileToIconOutput.finderResult,
  906.                 tellFinderMatchFileToIconOutput.oneDocOffset,
  907.                 tellFinderMatchFileToIconOutput.rBundleHandle,
  908.                 tellFinderMatchFileToIconOutput.smallIconHandle,
  909.                 tellFinderMatchFileToIconOutput.largeIconHandle,
  910.                 tellFinderMatchFileToIconOutput.rFInderPathHandle);
  911.             
  912.             /*
  913.             sprintf(AlertString,"90/pCount = $%x\tvotingBits = $%x\twhichMatch = $%xrfiletype = $%x\tauxtype = $%lxL\rmatchFilenamePtr = $%lxL\rcreateFileInfoPtr = $%lxL\rmodFileInfoPtr = $%lxL\rlocalAccess = $%x\tflags = $%x\roptionListPtr = $%lxL\rcombinedEOF = $%lxL/^OK",
  914.                 tellFinderMatchFileToIconInput.pCount,
  915.                 tellFinderMatchFileToIconInput.votingBits,
  916.                 tellFinderMatchFileToIconInput.whichMatch,
  917.                 tellFinderMatchFileToIconInput.filetype,
  918.                 tellFinderMatchFileToIconInput.auxtype,
  919.                 tellFinderMatchFileToIconInput.matchFilenamePtr,
  920.                 tellFinderMatchFileToIconInput.createFileInfoPtr,
  921.                 tellFinderMatchFileToIconInput.modFileInfoPtr,
  922.                 tellFinderMatchFileToIconInput.localAccess,
  923.                 tellFinderMatchFileToIconInput.flags,
  924.                 tellFinderMatchFileToIconInput.optionListPtr,
  925.                 tellFinderMatchFileToIconInput.combinedEOF);
  926.             */
  927.             AlertWindow (0x0000,NULL,AlertString);
  928.         }
  929. }
  930. /************************************************************************************************/
  931. /* A routine to see if the menu item ID from finderSaysExtrasChoosen belongs to me. If so I */
  932. /* handle it. If not, I exit */
  933.  
  934. int ItemBelongsToMe(MenuItemID)
  935. word    MenuItemID;
  936. {
  937.     int    i;
  938.     
  939.     for (i = 0; i < menuItemIndex; ++i)
  940.         {
  941.             if(MenuItemID == menuItemID[i])
  942.                 return 1;
  943.         }
  944.     return 0;
  945. }
  946.  
  947. /************************************************************************************************/
  948. /* All the stuff needed for all the AcceptRequests follows */
  949.  
  950. /* Define a union for the finderSays input buffer types */
  951.  
  952. typedef union    {
  953.     finderSaysHelloIn            finderSaysHelloInputBuffer;
  954.     finderSaysMItemSelectedIn    finderSaysMItemSelectedInputBuffer;
  955.     finderSaysBeforeOpenIn        finderSaysBeforeOpenInputBuffer;
  956.     finderSaysOpenFailedIn        finderSaysOpenFailedInputBuffer;
  957.     finderSaysBeforeCopyIn        finderSaysBeforeCopyInputBuffer;
  958.     finderSaysBeforeRenameIn    finderSaysBeforeRenameInputBuffer;
  959.     finderSaysKeyHitIn            finderSaysKeyHitInputBuffer;
  960.     } AcceptRequestDataIn;
  961.     
  962. typedef struct MyMytellFinderGetDebugInfoOut {
  963.     word     recvCount;
  964.     word     finderResult;
  965.     word     pCount;
  966.     word     directPage;
  967.     handle     deskIcon;
  968.     handle     nameChainH;
  969.     pointer filetypeBlock;
  970.     pointer deviceBlock;
  971.     handle     masterChainH;
  972.     handle     rFPListHandle;
  973.     word     rFPCount;
  974.     long    reserved1;  /* nameChainInsert */
  975.     long    reserved2;
  976.     long    reserved3;  /* masterChainInsert */
  977.     long    reserved4;
  978.     handle    chainTable;
  979.     handle    iconOffsetArray;
  980.     handle    iconHandleArray;
  981.     word    iconArrayUsed;
  982.     word    iconArraySize;
  983.     long    reserved5;
  984.     char    reserved[60];
  985.     } MytellFinderGetDebugInfoOut, *MytellFinderGetDebugInfoOutPtr;
  986.  
  987. /* Define my Request Procedures which are called by the various AcceptRequests Procs */
  988.  
  989. /* This one handles the finderSaysExtrasChosen request */
  990.  
  991. int finderSaysExtrasChosenProc (DataIn)
  992. long    DataIn;
  993. {
  994.     if (ItemBelongsToMe((word)DataIn))        /* Check to see if the extras menu item is one that I created. If it is, handle it. */
  995.         {
  996.             InitCursor ();
  997.             sprintf(AlertString,"40/Request Code = finderSaysExtrasChoosen\rMenu Item ID = $%x/^OK",
  998.                 DataIn);
  999.             AlertWindow (0x0000,NULL,AlertString);
  1000.             return 1;
  1001.         }
  1002.     return 0;
  1003. }
  1004.  
  1005. /* This one handles the finderSaysMItemSelected request */
  1006.  
  1007. finderSaysMItemSelectedProc(DataIn)
  1008. AcceptRequestDataIn         *DataIn;
  1009. {
  1010.     InitCursor ();
  1011.     sprintf(AlertString,"40/Request Code = finderSaysMItemSelected\rMenu Item ID = $%x\rMenu ID = $%x\rModifiers = $%x/^OK",
  1012.     DataIn -> finderSaysMItemSelectedInputBuffer.menuItemID,
  1013.     DataIn -> finderSaysMItemSelectedInputBuffer.menuID,
  1014.     DataIn -> finderSaysMItemSelectedInputBuffer.modifiers);
  1015.     AlertWindow(0x0000,NULL,AlertString);
  1016. }
  1017.  
  1018. /*
  1019.   PatchFinder60 (called with the dataIn value from finderSaysHello)
  1020.   
  1021.   Patches Finder 6.0 as specified in the Finder 6.0 documentation, to allow
  1022.   us to call tellFinderGetSelectedIcons (extended) and tellFinderGetWindowIcons
  1023.   (extended).
  1024.   
  1025.   by David A. Lyons, 25-Feb-92
  1026. */
  1027.  
  1028. void PatchFinder60(dataIn)
  1029.     finderSaysHelloInPtr dataIn;
  1030. {
  1031.     Handle mainSeg;
  1032.     char *main;
  1033.     if( dataIn->versNum == 0x0600A000)
  1034.       {
  1035.         mainSeg = FindHandle(dataIn);
  1036.         main = (char *) *mainSeg;
  1037.         *(unsigned *)(main+0x2E5A) = 0x0AA0;
  1038.         *(unsigned *)(main+0x2E5C) = 0x8000;
  1039.         *(unsigned *)(main+0x2E5E) = 0x003F;
  1040.       }
  1041. }
  1042.  
  1043. pascal int InitHelloRequestProc(Request,DataIn,DataOut)
  1044. unsigned                 Request;
  1045. AcceptRequestDataIn     *DataIn;
  1046. long                     DataOut;
  1047. {
  1048.     unsigned oldDB = SaveDB();
  1049.     
  1050.     if (Request == finderSaysHello)
  1051.         {
  1052.             PatchFinder60(DataIn);
  1053.             RestoreDB(oldDB);
  1054.             return (0x8000);
  1055.         }
  1056.     RestoreDB(oldDB);
  1057.     return (0x0000);
  1058. }
  1059.  
  1060. /* This proc handles the finderSaysHello request */
  1061.  
  1062. pascal int HelloRequestProc(Request,DataIn,DataOut)
  1063. unsigned                 Request;
  1064. AcceptRequestDataIn     *DataIn;
  1065. long                     DataOut;
  1066. {
  1067.     unsigned oldDB = SaveDB();
  1068.     
  1069.     if (Request == finderSaysHello)
  1070.         {
  1071.             InitCursor ();
  1072.             sprintf(AlertString,"40/Request Code = finderSaysHello\rFinder Version = $%lxL\rFinder ID = $%x\rIcon Object Size = $%x/^OK",
  1073.                 DataIn -> finderSaysHelloInputBuffer.versNum,
  1074.                 DataIn -> finderSaysHelloInputBuffer.finderUserID,
  1075.                 DataIn -> finderSaysHelloInputBuffer.iconObjectSize);
  1076.             AlertWindow (0x0000,NULL,AlertString);
  1077.             FinderMemoryID = DataIn -> finderSaysHelloInputBuffer.finderUserID;
  1078.             RestoreDB(oldDB);
  1079.             return (0x8000);
  1080.         }
  1081.     RestoreDB(oldDB);
  1082.     return (0x0000);
  1083. }
  1084.  
  1085. /* This proc handles the finderSaysGoodbye request */
  1086.  
  1087. pascal int GoodbyeRequestProc(Request,DataIn,DataOut)
  1088. unsigned                 Request;
  1089. AcceptRequestDataIn     *DataIn;
  1090. long                     DataOut;
  1091. {
  1092.     unsigned oldDB = SaveDB();
  1093.     
  1094.     if (Request == finderSaysGoodbye)
  1095.         {
  1096.             InitCursor ();
  1097.             AlertWindow (0x0000,NULL,"40/Request Code = finderSaysGoodbye\rDataIn and DataOut are reserved./^OK");
  1098.             RestoreDB(oldDB);
  1099.             return (0x8000);
  1100.         }
  1101.     RestoreDB(oldDB);
  1102.     return (0x0000);
  1103. }
  1104.  
  1105. /* This proc handles the finderSaysSelectionChanged request */
  1106.  
  1107. pascal int SelectionChangedRequestProc(Request,DataIn,DataOut)
  1108. unsigned                 Request;
  1109. AcceptRequestDataIn     *DataIn;
  1110. long                     DataOut;
  1111. {
  1112.     unsigned oldDB = SaveDB();
  1113.     
  1114.     if (Request == finderSaysSelectionChanged)
  1115.         {
  1116.             InitCursor ();
  1117.             AlertWindow (0x0000,NULL,"40/Request Code = finderSaysSelectionChanged\rDataIn and DataOut are reserved./^OK");
  1118.             RestoreDB(oldDB);
  1119.             return (0x8000);
  1120.         }
  1121.     RestoreDB(oldDB);
  1122.     return (0x0000);
  1123. }
  1124.  
  1125. /* This proc handles the finderSaysMItemSelected request */
  1126.  
  1127. pascal int MItemSelectedRequestProc(Request,DataIn,DataOut)
  1128. unsigned                     Request;
  1129. AcceptRequestDataIn         *DataIn;
  1130. finderSaysMItemSelectedOut     *DataOut;
  1131. {
  1132.     unsigned oldDB = SaveDB();
  1133.     
  1134.     if (Request == finderSaysMItemSelected)
  1135.         {
  1136.             InitCursor ();
  1137.             if(GetCtlValue(GetCtlHandleFromID(FinderXDAWindPtr,0x00000902L)) != 0x0000) /* Check the AbortItFlag control */
  1138.                 {
  1139.                     DataOut -> abortItFlag = 0x0001;    /* If control checked, tell the Finder not to hadle the selection */
  1140.                 }
  1141.             else
  1142.                 {
  1143.                     DataOut -> abortItFlag = 0x0000;    /* Else tell the Finder to handle the selection */
  1144.                 }
  1145.             finderSaysMItemSelectedProc(DataIn);
  1146.             RestoreDB(oldDB);
  1147.             return (0x8000);
  1148.         }
  1149.     RestoreDB(oldDB);
  1150.     return (0x0000);
  1151. }
  1152.  
  1153. /* This proc handles the finderSaysBeforeOpen request */
  1154.  
  1155. pascal int BeforeOpenRequestProc(Request,DataIn,DataOut)
  1156. unsigned             Request;
  1157. AcceptRequestDataIn *DataIn;
  1158. long                 DataOut;
  1159. {
  1160.     GSString255Ptr    PathnamePtr;
  1161.     static char     Pathname[255];
  1162.     unsigned         oldDB = SaveDB();
  1163.     
  1164.     if (Request == finderSaysBeforeOpen)
  1165.         {
  1166.             InitCursor ();
  1167.             PathnamePtr = (GSString255Ptr)(DataIn -> finderSaysBeforeOpenInputBuffer.pathname);
  1168.             strncpy(Pathname,PathnamePtr -> text,PathnamePtr -> length);
  1169.             Pathname[PathnamePtr -> length] = 0;
  1170.             sprintf(AlertString, "90/Request Code = finderSaysBeforeOpen\rpCount = $%x\rPathname Pointer = $%lxL\tZoom Rect Pointer = $%lxL\rFiletype = $%x\tAux Type = $%lxL\tModifiers = $%x\rIcon Obj = $%lx\tprintFlag = $%x\rPathname = %s/^OK",
  1171.                     DataIn -> finderSaysBeforeOpenInputBuffer.pCount,
  1172.                     DataIn -> finderSaysBeforeOpenInputBuffer.pathname,
  1173.                     DataIn -> finderSaysBeforeOpenInputBuffer.zoomRect,
  1174.                     DataIn -> finderSaysBeforeOpenInputBuffer.filetype,
  1175.                     DataIn -> finderSaysBeforeOpenInputBuffer.auxtype,
  1176.                     DataIn -> finderSaysBeforeOpenInputBuffer.modifiers,
  1177.                     DataIn -> finderSaysBeforeOpenInputBuffer.theIconObj,
  1178.                     DataIn -> finderSaysBeforeOpenInputBuffer.printFlag,
  1179.                     Pathname);
  1180.             AlertWindow (0x0000,0L,AlertString);
  1181.             RestoreDB(oldDB);
  1182.             return (0x8000);
  1183.         }
  1184.     RestoreDB(oldDB);
  1185.     return (0x0000);
  1186. }
  1187.  
  1188. /* This proc handles the finderSaysOpenFailed request */
  1189.  
  1190. pascal int OpenFailedRequestProc(Request,DataIn,DataOut)
  1191. unsigned             Request;
  1192. AcceptRequestDataIn *DataIn;
  1193. long                 DataOut;
  1194. {
  1195.     GSString255Ptr    PathnamePtr;
  1196.     static char     Pathname[255];
  1197.     unsigned         oldDB = SaveDB();
  1198.     
  1199.     if (Request == finderSaysOpenFailed)
  1200.         {
  1201.             InitCursor ();
  1202.             PathnamePtr = (GSString255Ptr)(DataIn -> finderSaysOpenFailedInputBuffer.pathname);
  1203.             strncpy(Pathname,PathnamePtr -> text,PathnamePtr -> length);
  1204.             Pathname[PathnamePtr -> length] = 0;
  1205.             sprintf(AlertString, "90/Request Code = finderSaysOpenFailed\rpCount = $%x\rPathname Pointer = $%lxL\tZoom Rect Pointer = $%lxL\rFiletype = $%x\tAux Type = $%lxL\tModifiers = $%x\rIcon Obj = $%lx\tprintFlag = $%x\rPathname = %s/^OK",
  1206.                 DataIn -> finderSaysOpenFailedInputBuffer.pCount,
  1207.                 DataIn -> finderSaysOpenFailedInputBuffer.pathname,
  1208.                 DataIn -> finderSaysOpenFailedInputBuffer.zoomRect,
  1209.                 DataIn -> finderSaysOpenFailedInputBuffer.filetype,
  1210.                 DataIn -> finderSaysOpenFailedInputBuffer.auxtype,
  1211.                 DataIn -> finderSaysOpenFailedInputBuffer.modifiers,
  1212.                 DataIn -> finderSaysBeforeOpenInputBuffer.theIconObj,
  1213.                 DataIn -> finderSaysBeforeOpenInputBuffer.printFlag,
  1214.                 Pathname);
  1215.             AlertWindow (0x0000,0L,AlertString);
  1216.             RestoreDB(oldDB);
  1217.             return (0x8000);
  1218.         }
  1219.     RestoreDB(oldDB);
  1220.     return (0x0000);
  1221. }
  1222.  
  1223. /* This proc handles the finderSaysBeforeCopy request */
  1224.  
  1225. pascal int BeforeCopyRequestProc(Request,DataIn, DataOut)
  1226. unsigned                 Request;
  1227. AcceptRequestDataIn     *DataIn;
  1228. finderSaysBeforeCopyOut *DataOut;
  1229. {
  1230.     GSString255Ptr    sourcePathnamePtr;
  1231.     GSString255Ptr    destinationPathnamePtr;
  1232.     char            *subArray[2];
  1233.     int                sourcePathnameLength;
  1234.     int                destinationPathnameLength;
  1235.     char            *pSource;
  1236.     char            *pDestination;
  1237.     word            ButtonSelected;
  1238.     unsigned         oldDB = SaveDB();
  1239.     
  1240.     if(Request == finderSaysBeforeCopy)
  1241.         {
  1242.             InitCursor ();
  1243.             sourcePathnamePtr = (GSString255Ptr)(DataIn -> finderSaysBeforeCopyInputBuffer.sourcePathname);
  1244.             subArray[0] = (char *)sourcePathnamePtr + 1;
  1245.             sourcePathnameLength = sourcePathnamePtr -> length;
  1246.             pSource = (char *)sourcePathnamePtr;
  1247.             pSource[1] = pSource[0];
  1248.             destinationPathnamePtr = (GSString255Ptr)(DataIn -> finderSaysBeforeCopyInputBuffer.destinationPathname);
  1249.             subArray[1] = (char *)destinationPathnamePtr + 1;
  1250.             destinationPathnameLength = destinationPathnamePtr -> length;
  1251.             pDestination = (char *)destinationPathnamePtr;
  1252.             pDestination[1] = pDestination[0];
  1253.             sprintf(AlertString,"90/Request Code = finderSaysBeforeCopy\rpCount = $%x\rSource Pathname Ptr = $%lxL\rDestination Pathname Ptr = $%lxL\rSource Pathname = *0\rDestination Pathname = *1/^Allow Copy/Cancel",
  1254.                 DataIn -> finderSaysBeforeCopyInputBuffer.pCount,
  1255.                 DataIn -> finderSaysBeforeCopyInputBuffer.sourcePathname,
  1256.                 DataIn -> finderSaysBeforeCopyInputBuffer.destinationPathname);
  1257.             ButtonSelected = AlertWindow (0x0001,subArray,AlertString);
  1258.             sourcePathnamePtr -> length = sourcePathnameLength;
  1259.             destinationPathnamePtr -> length = destinationPathnameLength;
  1260.             if (ButtonSelected == 0x0001)                                        /* Check the AlertWindow button selected to see if the copy should be allowed, */
  1261.                 {                                                                /* if = 1, don't allow it */
  1262.                     DataOut -> abortFlag = 0x0001;
  1263.                 }
  1264.             RestoreDB(oldDB);
  1265.             return 0x8000;
  1266.         }
  1267.     RestoreDB(oldDB);
  1268.     return 0x0000;
  1269. }
  1270.  
  1271. /* This proc handles the finderSaysIdle request */
  1272.  
  1273. pascal int IdleRequestProc(Request,DataIn,DataOut)
  1274. unsigned     Request;
  1275. long         DataIn;
  1276. long         DataOut;
  1277. {
  1278.     WindowPtr    OldPort;
  1279.     unsigned     oldDB = SaveDB();    
  1280.     
  1281.     if (Request == finderSaysIdle)
  1282.         {
  1283.             OldPort = GetPort();
  1284.             SetPort(FinderXDAWindPtr);
  1285.             SetRect(&IdleRect,390,52,410,62);
  1286.             if (finderSaysIdleFlag == 0)
  1287.                 {
  1288.                     PaintRect(&IdleRect);
  1289.                     ++finderSaysIdleFlag;
  1290.                 }
  1291.             else
  1292.                 {
  1293.                     EraseRect(&IdleRect);
  1294.                     --finderSaysIdleFlag;
  1295.                 }
  1296.             SetPort(OldPort);
  1297.             RestoreDB(oldDB);
  1298.             return 0x8000;
  1299.         }
  1300.     RestoreDB(oldDB);
  1301.     return 0x0000;
  1302. }
  1303.  
  1304. DisposeIdleProc()
  1305. {
  1306.     WindowPtr    OldPort;
  1307.     
  1308.     AcceptRequests ("\pAppleComputer~FinderXDAIdle~",MMStartUp(),0L);
  1309.     OldPort = GetPort();
  1310.     SetPort(FinderXDAWindPtr);
  1311.     EraseRect(&IdleRect);
  1312.     SetPort(OldPort);
  1313. }
  1314.  
  1315. /* This proc handles the finderSaysExtrasChosen request */
  1316.  
  1317. pascal int ExtrasChosenRequestProc(Request,DataIn,DataOut)
  1318. unsigned                 Request;
  1319. AcceptRequestDataIn     *DataIn;
  1320. long                     DataOut;
  1321. {
  1322.     unsigned oldDB = SaveDB();
  1323.     
  1324.     if (Request == finderSaysExtrasChosen)
  1325.         {
  1326.             InitCursor ();
  1327.             finderSaysExtrasChosenProc(DataIn);
  1328.             RestoreDB(oldDB);
  1329.             return (0x8000);
  1330.         }
  1331.     RestoreDB(oldDB);
  1332.     return (0x0000);
  1333. }
  1334.  
  1335. /* This proc handles the finderSaysBeforeRename request */
  1336.  
  1337. pascal int BeforeRenameRequestProc(Request,DataIn,DataOut)
  1338. unsigned                     Request;
  1339. AcceptRequestDataIn         *DataIn;
  1340. finderSaysBeforeRenameOut     *DataOut;
  1341. {
  1342.     GSString255Ptr    oldPathnamePtr;
  1343.     GSString255Ptr    newPathnamePtr;
  1344.     char            *subArray[2];
  1345.     int                oldPathnameLength;
  1346.     int                newPathnameLength;
  1347.     char            *pOld;
  1348.     char            *pNew;
  1349.     word            ButtonSelected;
  1350.     unsigned         oldDB = SaveDB();
  1351.     
  1352.     if (Request == finderSaysBeforeRename)
  1353.         {
  1354.             InitCursor ();
  1355.             oldPathnamePtr = (GSString255Ptr)(DataIn -> finderSaysBeforeRenameInputBuffer.oldPathname);
  1356.             subArray[0] = (char *)oldPathnamePtr + 1;
  1357.             oldPathnameLength = oldPathnamePtr -> length;
  1358.             pOld = (char *)oldPathnamePtr;
  1359.             pOld[1] = pOld[0];
  1360.             newPathnamePtr = (GSString255Ptr)(DataIn -> finderSaysBeforeRenameInputBuffer.newPathname);
  1361.             subArray[1] = (char *)newPathnamePtr + 1;
  1362.             newPathnameLength = newPathnamePtr -> length;
  1363.             pNew = (char *)newPathnamePtr;
  1364.             pNew[1] = pNew[0];
  1365.             sprintf(AlertString,"90/Request Code = finderSaysBeforeRename\rpCount = $%x\rOld Pathname Pointer = $%lxL\tNew Pathname Pointer = $%lxL\rFile Type = $%x\tFile Aux Type = $%lxL\rOld Pathname = *0\rNew Pathname = *1/^Allow Rename/Cancel",
  1366.                 DataIn -> finderSaysBeforeRenameInputBuffer.pCount,
  1367.                 DataIn -> finderSaysBeforeRenameInputBuffer.oldPathname,
  1368.                 DataIn -> finderSaysBeforeRenameInputBuffer.newPathname,
  1369.                 DataIn -> finderSaysBeforeRenameInputBuffer.filetype,
  1370.                 DataIn -> finderSaysBeforeRenameInputBuffer.auxtype);
  1371.             ButtonSelected = AlertWindow (0x0001,subArray,AlertString);
  1372.             oldPathnamePtr -> length = oldPathnameLength;
  1373.             newPathnamePtr -> length = newPathnameLength;
  1374.             if (ButtonSelected == 0x0001)
  1375.                 {
  1376.                     DataOut -> abortFlag = 0x0001;
  1377.                 }
  1378.             RestoreDB(oldDB);
  1379.             return 0x8000;
  1380.         }
  1381.     RestoreDB(oldDB);
  1382.     return 0x0000;
  1383. }
  1384.  
  1385. /* This proc handles the finderSaysKeyHit request */
  1386.  
  1387. pascal int KeyHitRequestProc(Request,DataIn,DataOut)
  1388. unsigned             Request;
  1389. AcceptRequestDataIn *DataIn;
  1390. long                 DataOut;
  1391. {
  1392.     unsigned oldDB = SaveDB();
  1393.     
  1394.     if (Request == finderSaysKeyHit)
  1395.         {
  1396.         InitCursor ();
  1397.         sprintf(AlertString,"40/Request Code = finderSaysKeyHit\rpCount = $%x\rTaskMaster Message = $%x\rModifiers = $%x/^OK",
  1398.             DataIn -> finderSaysKeyHitInputBuffer.pCount,
  1399.             DataIn -> finderSaysKeyHitInputBuffer.message,
  1400.             DataIn -> finderSaysKeyHitInputBuffer.modifiers);
  1401.         AlertWindow (0x0000,NULL,AlertString);
  1402.         RestoreDB(oldDB);
  1403.         return 0x8000;
  1404.         }
  1405.     RestoreDB(oldDB);
  1406.     return 0x0000;
  1407. }
  1408.  
  1409. /* A function to remove all the AcceptRequest procs */
  1410.  
  1411. RemoveRequestProcs ()
  1412. {
  1413.     AcceptRequests ("\pAppleComputer~FinderXDAHello~",MMStartUp(),0L);
  1414.     AcceptRequests ("\pAppleComputer~FinderXDAGoodbye~",MMStartUp(),0L);
  1415.     AcceptRequests ("\pAppleComputer~FinderXDASelectionChanged~",MMStartUp(),0L);
  1416.     AcceptRequests ("\pAppleComputer~FinderXDAMItemSelected~",MMStartUp(),0L);
  1417.     AcceptRequests ("\pAppleComputer~FinderXDABeforeOpen~",MMStartUp(),0L);
  1418.     AcceptRequests ("\pAppleComputer~FinderXDAOpenFailed~",MMStartUp(),0L);
  1419.     AcceptRequests ("\pAppleComputer~FinderXDABeforeCopy~",MMStartUp(),0L);
  1420.     DisposeIdleProc();
  1421.     AcceptRequests ("\pAppleComputer~FinderXDAExtrasChosen~",MMStartUp(),0L);
  1422.     AcceptRequests ("\pAppleComputer~FinderXDABeforeRename~",MMStartUp(),0L);
  1423.     AcceptRequests ("\pAppleComputer~FinderXDAKeyHit~",MMStartUp(),0L);
  1424.     AcceptRequests ("\pAppleComputer~FinderXDA~",MMStartUp(),0L);
  1425. }
  1426.  
  1427. /************************************************************************************************/
  1428.  
  1429. /* tellFinder Request Code Handling Procedures */
  1430.  
  1431. tellFinderGetDebugInfoProc ()
  1432. {
  1433.     MytellFinderGetDebugInfoOut    MytellFinderGetDebugInfoOutput;
  1434.     CtlRecHndl                    DebugInfoCtlHandle;
  1435.     word                        ButtonSelected;
  1436.     
  1437.     if(DebugInfoWindPtr == 0)
  1438.         {
  1439.             SendRequest (tellFinderGetDebugInfo,0x8001,finderTarget,0L,(long)&MytellFinderGetDebugInfoOutput);
  1440.             sprintf(AlertString,"Request Code = tellFinderGetDebugInfo\rrecvCount = $%x\rResult Code = $%x\rpCount = $%x\rDirect Page = $%x\rdeskIC = $%lxL\rnameChainH = $%lxL\rfiletypeBlock = $%lxL\rdeviceBlock = $%lxL\rmasterChainH = $%lxL\rfinderPathsH = $%lxL\rfinderPathsCount = $%x\rchainTable = $%lx\riconOffsetArray = $%lx\riconHandleArray = $%lx\riconArrayUsed = $%x\riconArraySize = $%x",
  1441.                 MytellFinderGetDebugInfoOutput.recvCount,
  1442.                 MytellFinderGetDebugInfoOutput.finderResult,
  1443.                 MytellFinderGetDebugInfoOutput.pCount,
  1444.                 MytellFinderGetDebugInfoOutput.directPage,
  1445.                 MytellFinderGetDebugInfoOutput.deskIcon,
  1446.                 MytellFinderGetDebugInfoOutput.nameChainH,
  1447.                 MytellFinderGetDebugInfoOutput.filetypeBlock,
  1448.                 MytellFinderGetDebugInfoOutput.deviceBlock,
  1449.                 MytellFinderGetDebugInfoOutput.masterChainH,
  1450.                 MytellFinderGetDebugInfoOutput.rFPListHandle,
  1451.                 MytellFinderGetDebugInfoOutput.rFPCount,
  1452.                 MytellFinderGetDebugInfoOutput.chainTable,
  1453.                 MytellFinderGetDebugInfoOutput.iconOffsetArray,
  1454.                 MytellFinderGetDebugInfoOutput.iconHandleArray,
  1455.                 MytellFinderGetDebugInfoOutput.iconArrayUsed,
  1456.                 MytellFinderGetDebugInfoOutput.iconArraySize);                
  1457.  
  1458.             DebugInfoWindPtr = NewWindow (&DebugInfoWindParams);
  1459.             if(_toolErr) CheckError(_toolErr,0x0001);
  1460.             else
  1461.                 {
  1462.                     SetUpDebugInfoNDASysWindRec();
  1463.                     SetSysWindow(DebugInfoWindPtr);
  1464.                     DebugInfoAuxWindRecPtr = (AuxWindInfoPtr)(GetAuxWindInfo(DebugInfoWindPtr));
  1465.                     DebugInfoAuxWindRecPtr -> NDASysWindPtr = (Ptr)&DebugInfoNDASysWindRec;
  1466.                     
  1467.                     DebugInfoCtlHandle = NewControl2(DebugInfoWindPtr,0,&MyWindCtl);
  1468.                     if(_toolErr) CheckError(_toolErr,0x0001);
  1469.                     TEInsert (0x0001,AlertString,0L,0,0L,DebugInfoCtlHandle);
  1470.                     (**(TERecordHndl)GetCtlHandleFromID(NIL,0x00001000L)).textFlags |= 0x04000000;
  1471.                 }
  1472.         }
  1473.     else
  1474.         {
  1475.             ButtonSelected = AlertWindow (0x0000,0L,"42/A tellFinderGetGetDebugInfo window is already open. Do you want to close it?/^Close Window/Cancel");
  1476.             if (ButtonSelected == 0)
  1477.                 {
  1478.                     CloseIfOpen(&DebugInfoWindPtr);
  1479.                 }
  1480.         }
  1481. }
  1482.     
  1483. tellFinderAreYouThereProc ()
  1484. {
  1485.     tellFinderAreYouThereOut    tellFinderAreYouThereOutput;
  1486.     
  1487.     SendRequest (askFinderAreYouThere,0x8001,finderTarget,0L,&tellFinderAreYouThereOutput);
  1488.     CheckError(tellFinderAreYouThereOutput.finderResult,0x0000);
  1489.     sprintf(AlertString,"40/Request Code = tellFinderAreYouThere\rrecvCount = $%x\rResult Code = $%x\rError - %s/^OK",
  1490.         tellFinderAreYouThereOutput.recvCount,
  1491.         tellFinderAreYouThereOutput.finderResult,
  1492.         ErrorString);
  1493.     AlertWindow (0x0000,0L,AlertString);    
  1494. }
  1495.  
  1496. tellFinderOpenWindowProc ()
  1497. {
  1498.     tellFinderOpenWindowOut        tellFinderOpenWindowOutput;
  1499.     GSString255                 Pathname;
  1500.     long                        PathnameLength;
  1501.  
  1502.     PathnameLength = TEGetText (0x0002,(long)&Pathname,110L,0x0000,0L,0L);
  1503.     if(PathnameLength == NIL)
  1504.         {
  1505.             AlertWindow (0x0000,0L,"42/You passed an empty pathname. Please enter a pathname and try again./^Continue");
  1506.         }
  1507.     else
  1508.         {
  1509.             if(_toolErr) CheckError(_toolErr,0x0001);
  1510.             else
  1511.                 {
  1512.                     SendRequest (tellFinderOpenWindow,0x8001,finderTarget,&Pathname,(long)&tellFinderOpenWindowOutput);
  1513.                     CheckError(tellFinderOpenWindowOutput.finderResult,0x0000);
  1514.                     sprintf(AlertString,"40/Request Code = tellFinderOpenWindow\rrecvCount = $%x\rResult Code = $%x\rWindow Pointer = $%lxL\rError - %s/^OK",
  1515.                         tellFinderOpenWindowOutput.recvCount,
  1516.                         tellFinderOpenWindowOutput.finderResult,
  1517.                         tellFinderOpenWindowOutput.window,
  1518.                         ErrorString);
  1519.                     AlertWindow (0x0000,0L,AlertString);
  1520.                 }
  1521.         }
  1522. }
  1523.  
  1524. tellFinderCloseWindowProc ()
  1525. {
  1526.     tellFinderCloseWindowOut    tellFinderCloseWindowOutput;
  1527.     GSString255                 Pathname;
  1528.     long                        PathnameLength;
  1529.  
  1530.     PathnameLength = TEGetText (0x0002,(long)&Pathname,110L,0x0000,0L,0L);
  1531.     if(PathnameLength == NIL)
  1532.         {
  1533.             AlertWindow (0x0000,0L,"42/You passed an empty pathname. Please enter a pathname and try again./^Continue");
  1534.         }
  1535.     else
  1536.         {
  1537.             if(_toolErr) CheckError(_toolErr,0x0001);
  1538.             else
  1539.                 {
  1540.                     SendRequest (tellFinderCloseWindow,0x8001,finderTarget,&Pathname,(long)&tellFinderCloseWindowOutput);
  1541.                     CheckError(tellFinderCloseWindowOutput.finderResult,0x0000);
  1542.                     sprintf(AlertString,"40/Request Code = tellFinderCloseWindow\rrecvCount = $%x\rResult Code = $%x\rError - %s/^OK",
  1543.                         tellFinderCloseWindowOutput.recvCount,
  1544.                         tellFinderCloseWindowOutput.finderResult,
  1545.                         ErrorString);
  1546.                     AlertWindow (0x0000,0L,AlertString);
  1547.                 }
  1548.         }
  1549. }
  1550.  
  1551. /* This function is called by the tellFinderGetSelectedIconsProc and the tellFinderGetWindowIconsProc for */
  1552. /* outputing extended icon data to the result window and advancing the pointeraddress */
  1553.  
  1554. OutputAWord(MyString,PointerAddress,PathnameCtlHandle)
  1555. char        MyString[];
  1556. Ptr            *PointerAddress;
  1557. CtlRecHndl    PathnameCtlHandle;
  1558. {
  1559.     char    wordString[4];
  1560.     
  1561.     TEInsert (0x0001,MyString,0L,0,0L,PathnameCtlHandle);
  1562.     if(_toolErr) CheckError(_toolErr,0x0001);
  1563.     Int2Hex(**(word **)PointerAddress,wordString,4);
  1564.     TEInsert (0x0005,wordString,4L,0,0L,PathnameCtlHandle);
  1565.     if(_toolErr) CheckError(_toolErr,0x0001);
  1566.     TEInsert (0x0001,"\r",0L,0,0L,PathnameCtlHandle);
  1567.     if(_toolErr) CheckError(_toolErr,0x0001);
  1568.     *PointerAddress += 2;
  1569. }
  1570.  
  1571. tellFinderGetSelectedIconsProc ()
  1572. {
  1573.     CtlRecHndl                            PathnameCtlHandle;
  1574.     Ptr                                    PointerAddress;
  1575.     Ptr                                    StringAddress;
  1576.     int                                    i;
  1577.     word                                ButtonSelected;
  1578.     word                                yIcon;
  1579.     word                                xIcon;
  1580.     word                                yIconText;
  1581.     word                                iconHeight;
  1582.     word                                iconWidth;
  1583.     char                                yIconString[4];
  1584.     char                                xIconString[4];
  1585.     char                                yIconTextString[4];
  1586.     char                                iconHeightString[4];
  1587.     char                                iconWidthString[4];
  1588.     
  1589.     if(GetSelectedIconsWindPtr == 0)
  1590.         {
  1591.             if (tellFinderGetSelectedIconsOutput.stringListHandle != NIL)
  1592.             {
  1593.                 DisposeHandle((long)tellFinderGetSelectedIconsOutput.stringListHandle &~0x80000000L);
  1594.                 if(_toolErr) CheckError(_toolErr,0x0001);
  1595.                 tellFinderGetSelectedIconsOutput.stringListHandle = NIL;
  1596.             }
  1597.             if(GetCtlValue(GetCtlHandleFromID(GetSelectedIconsWindPtr,0x00000903L)) == 0)
  1598.                 {
  1599.                     SendRequest (tellFinderGetSelectedIcons,0x8001,finderTarget,0L,(long)&tellFinderGetSelectedIconsOutput);
  1600.                     sprintf(AlertString,"40/Request Code = tellFinderGetSelectedIcons\rrecvCount = $%x\tResult Code = $%x\rIcon Window Pointer = $%lxL\rStringList Handle = $%lxL\rNumber of Pathnames to follow = $%x/^OK",
  1601.                         tellFinderGetSelectedIconsOutput.recvCount,
  1602.                         tellFinderGetSelectedIconsOutput.finderResult,
  1603.                         tellFinderGetSelectedIconsOutput.iconWindowPtr,
  1604.                         tellFinderGetSelectedIconsOutput.stringListHandle,
  1605.                         **(word **)tellFinderGetSelectedIconsOutput.stringListHandle);
  1606.                     AlertWindow (0x0000,0L,AlertString);
  1607.                     if ((**(word **)tellFinderGetSelectedIconsOutput.stringListHandle) != 0)
  1608.                         {
  1609.                         GetSelectedIconsWindPtr = NewWindow (&GetSelectedIconsWindParams);
  1610.                         if(_toolErr) CheckError(_toolErr,0x0001);
  1611.                         else
  1612.                             {
  1613.                                 SetUpGetSelectedIconsNDASysWindRec();
  1614.                                 SetSysWindow(GetSelectedIconsWindPtr);
  1615.                                 GetSelectedIconsAuxWindRecPtr = (AuxWindInfoPtr)(GetAuxWindInfo(GetSelectedIconsWindPtr));
  1616.                                 GetSelectedIconsAuxWindRecPtr -> NDASysWindPtr = (Ptr)&GetSelectedIconsNDASysWindRec;
  1617.                                 PathnameCtlHandle = NewControl2(GetSelectedIconsWindPtr,0,&MyWindCtl);
  1618.                                 if(_toolErr) CheckError(_toolErr,0x0001);
  1619.                                 else
  1620.                                     {
  1621.                                         PointerAddress = (*tellFinderGetSelectedIconsOutput.stringListHandle)+2;
  1622.                                         for (i = 0; i < **(word **)tellFinderGetSelectedIconsOutput.stringListHandle; i++)
  1623.                                             {
  1624.                                                 TEInsert (0x0002,PointerAddress,0L,0,0L,PathnameCtlHandle);
  1625.                                                 if(_toolErr) CheckError(_toolErr,0x0001);
  1626.                                                 TEInsert (0x0001,"\r\r",0L,0,0L,PathnameCtlHandle);
  1627.                                                 if(_toolErr) CheckError(_toolErr,0x0001);
  1628.                                                 PointerAddress += *(word *)PointerAddress + 2;
  1629.                                             }
  1630.                                         (**(TERecordHndl)GetCtlHandleFromID(NIL,0x00001000L)).textFlags |= 0x04000000;
  1631.                                     }
  1632.                             }
  1633.                         }
  1634.                 }
  1635.             else
  1636.                 {
  1637.                     SendRequest (tellFinderGetSelectedIcons,0x8001,finderTarget,0x80000000L,(long)&tellFinderGetSelectedIconsOutput);
  1638.                     sprintf(AlertString,"40/Request Code = tellFinderGetSelectedIcons\rrecvCount = $%x\tResult Code = $%x\rIcon Window Pointer = $%lxL\rStringList Handle = $%lxL\rNumber of Pathnames to follow = $%x/^OK",
  1639.                         tellFinderGetSelectedIconsOutput.recvCount,
  1640.                         tellFinderGetSelectedIconsOutput.finderResult,
  1641.                         tellFinderGetSelectedIconsOutput.iconWindowPtr,
  1642.                         tellFinderGetSelectedIconsOutput.stringListHandle,
  1643.                         **(word **)tellFinderGetSelectedIconsOutput.stringListHandle);
  1644.                     AlertWindow (0x0000,0L,AlertString);
  1645.                     if ((**(word **)tellFinderGetSelectedIconsOutput.stringListHandle) != 0)
  1646.                         {
  1647.                         GetSelectedIconsWindPtr = NewWindow (&GetSelectedIconsWindParams);
  1648.                         if(_toolErr) CheckError(_toolErr,0x0001);
  1649.                         else
  1650.                             {
  1651.                                 SetUpGetSelectedIconsNDASysWindRec();
  1652.                                 SetSysWindow(GetSelectedIconsWindPtr);
  1653.                                 GetSelectedIconsAuxWindRecPtr = (AuxWindInfoPtr)(GetAuxWindInfo(GetSelectedIconsWindPtr));
  1654.                                 GetSelectedIconsAuxWindRecPtr -> NDASysWindPtr = (Ptr)&GetSelectedIconsNDASysWindRec;
  1655.                                 PathnameCtlHandle = NewControl2(GetSelectedIconsWindPtr,0,&MyWindCtl);
  1656.                                 if(_toolErr) CheckError(_toolErr,0x0001);
  1657.                                 else
  1658.                                     {
  1659.                                         HLock((long)tellFinderGetSelectedIconsOutput.stringListHandle &~0x80000000);
  1660.                                         PointerAddress = (*tellFinderGetSelectedIconsOutput.stringListHandle)+2;
  1661.                                         for (i = 0; i < **(word **)tellFinderGetSelectedIconsOutput.stringListHandle; i++)
  1662.                                             {
  1663.                                                 StringAddress = *(word *)PointerAddress + PointerAddress;
  1664.                                                 TEInsert (0x0001,"\r",0L,0,0L,PathnameCtlHandle);
  1665.                                                 TEInsert (0x0002,StringAddress,0L,0,0L,PathnameCtlHandle);
  1666.                                                 TEInsert (0x0001,"\r",0L,0,0L,PathnameCtlHandle);
  1667.                                                 PointerAddress += 2;
  1668.                                                 OutputAWord("\ty coordinate (bottom) of Icon, Icon view - $",&PointerAddress,PathnameCtlHandle);
  1669.                                                 OutputAWord("\tx coordinate (middle) of Icon, Icon view - $",&PointerAddress,PathnameCtlHandle);
  1670.                                                 OutputAWord("\ty coordinate of Icon, list view - $",&PointerAddress,PathnameCtlHandle);
  1671.                                                 OutputAWord("\tHeight of Icon for current view - $",&PointerAddress,PathnameCtlHandle);
  1672.                                                 OutputAWord("\tWidth of Icon for current view - $",&PointerAddress,PathnameCtlHandle);
  1673.                                                 PointerAddress = StringAddress + *(word *)StringAddress + 2;
  1674.                                             }
  1675.                                         HUnlock((long)tellFinderGetSelectedIconsOutput.stringListHandle &~0x80000000);
  1676.                                         (**(TERecordHndl)GetCtlHandleFromID(NIL,0x00001000L)).textFlags |= 0x04000000;
  1677.                                     }
  1678.                             }
  1679.                         }
  1680.                 }
  1681.         }
  1682.     else
  1683.         {
  1684.             ButtonSelected = AlertWindow (0x0000,0L,"42/A tellFinderGetSelectedIcons window is already open. Do you want to close it?/^Close Window/Cancel");
  1685.             if (ButtonSelected == 0)
  1686.                 {
  1687.                     CloseIfOpen(&GetSelectedIconsWindPtr);
  1688.                 }
  1689.         }
  1690. }
  1691.     
  1692. tellFinderSetSelectedIconsProc ()
  1693. {
  1694.     tellFinderSetSelectedIconsOut        tellFinderSetSelectedIconsOutput;
  1695.     
  1696.     if(GetCtlValue(GetCtlHandleFromID(FinderXDAWindPtr,0x0000805AL)) == 0x0001)
  1697.         {
  1698.             tellFinderGetSelectedIconsOutput.stringListHandle = (handle)(((long)tellFinderGetSelectedIconsOutput.stringListHandle) | 0x80000000L);
  1699.         }
  1700.     else
  1701.         {
  1702.             tellFinderGetSelectedIconsOutput.stringListHandle = (handle)(((long)tellFinderGetSelectedIconsOutput.stringListHandle) & ~0x80000000L);
  1703.         }
  1704.     SendRequest (tellFinderSetSelectedIcons,0x8001,finderTarget,tellFinderGetSelectedIconsOutput.stringListHandle,(long)&tellFinderSetSelectedIconsOutput);
  1705.     CheckError(tellFinderSetSelectedIconsOutput.finderResult,0x0000);
  1706.     sprintf(AlertString,"40/Request Code = tellFinderSetSelectedIcons\rrecvCount = $%x\rResult Code = $%x\rError - %s/^OK",
  1707.         tellFinderSetSelectedIconsOutput.recvCount,
  1708.         tellFinderSetSelectedIconsOutput.finderResult,
  1709.         ErrorString);
  1710.     AlertWindow (0x0000,0L,AlertString);    
  1711. }
  1712.  
  1713. tellFinderLaunchThis_Ap_Proc ()
  1714. {
  1715.     tellFinderLaunchThisIn        tellFinderLaunchThisInput;
  1716.     tellFinderLaunchThisOut        tellFinderLaunchThisOutput;
  1717.     GSString255                 Class1Pathname;
  1718.     
  1719.     TEGetText (0x0002,(long)&Class1Pathname,110L,0x0000,0L,0L);
  1720.     if(_toolErr) CheckError(_toolErr,0x0001);
  1721.     else
  1722.         {
  1723.             tellFinderLaunchThisInput.launchprint = 0x0000;
  1724.             tellFinderLaunchThisInput.pathname = (ptr)&Class1Pathname;
  1725.             SendRequest (tellFinderLaunchThis,0x8001,finderTarget,&tellFinderLaunchThisInput,(long)&tellFinderLaunchThisOutput);
  1726.             CheckError(tellFinderLaunchThisOutput.finderResult,0x0000);
  1727.             sprintf(AlertString,"40/Request Code = tellFinderLaunchThis_Ap\rrecvCount = $%x\rResult Code = $%x\rError - %s/^OK",
  1728.                 tellFinderLaunchThisOutput.recvCount,
  1729.                 tellFinderLaunchThisOutput.finderResult,
  1730.                 ErrorString);
  1731.             AlertWindow (0x0000,0L,AlertString);
  1732.             CloseFromNDA();
  1733.         }
  1734. }
  1735.  
  1736. tellFinderShutDown_PowerOff_Proc ()
  1737. {
  1738.     tellFinderShutDownOut    tellFinderShutDownOutput;
  1739.     
  1740.     SendRequest (tellFinderShutDown,0x8001,finderTarget,0x00000000L,(long)&tellFinderShutDownOutput);
  1741.     CheckError(tellFinderShutDownOutput.finderResult,0x0000);
  1742.     sprintf(AlertString,"80/Request Code = tellFinderShutDown_PowerOff\rrecvCount = $%x\rResult Code = $%x\rError - %s/^OK",
  1743.         tellFinderShutDownOutput.recvCount,
  1744.         tellFinderShutDownOutput.finderResult,
  1745.         ErrorString);
  1746.     AlertWindow (0x0000,0L,AlertString);    
  1747.     CloseFromNDA();
  1748. }
  1749.  
  1750. tellFinderShutDown_Restart_Proc ()
  1751. {
  1752.     tellFinderShutDownOut    tellFinderShutDownOutput;
  1753.     
  1754.     SendRequest (tellFinderShutDown,0x8001,finderTarget,0x00000001L,(long)&tellFinderShutDownOutput);
  1755.     CheckError(tellFinderShutDownOutput.finderResult,0x0000);
  1756.     sprintf(AlertString,"80/Request Code = tellFinderShutDown_Restart\rrecvCount = $%x\rResult Code = $%x\rError - %s/^OK",
  1757.         tellFinderShutDownOutput.recvCount,
  1758.         tellFinderShutDownOutput.finderResult,
  1759.         ErrorString);
  1760.     AlertWindow (0x0000,0L,AlertString);    
  1761.     CloseFromNDA();
  1762. }
  1763.  
  1764. tellFinderShutDown_QuitFinder_Proc ()
  1765. {
  1766.     tellFinderShutDownOut    tellFinderShutDownOutput;
  1767.     
  1768.     SendRequest (tellFinderShutDown,0x8001,finderTarget,0x00000002L,(long)&tellFinderShutDownOutput);
  1769.     CheckError(tellFinderShutDownOutput.finderResult,0x0000);
  1770.     sprintf(AlertString,"80/Request Code = tellFinderShutDown_QuitFinder\rrecvCount = $%x\rResult Code = $%x\rError - %s/^OK",
  1771.         tellFinderShutDownOutput.recvCount,
  1772.         tellFinderShutDownOutput.finderResult,
  1773.         ErrorString);
  1774.     AlertWindow (0x0000,0L,AlertString);    
  1775.     CloseFromNDA();
  1776. }
  1777.  
  1778. tellFinderMItemSelectedProc(MItemSelectedID)
  1779. word MItemSelectedID;
  1780. {
  1781.     GrafPortPtr                    VisWindPtr;
  1782.     tellFinderMItemSelectedIn    tellFinderMItemSelectedInput;
  1783.     tellFinderMItemSelectedOut    tellFinderMItemSelectedOutput;
  1784.     tellFinderOpenWindowOut        tellFinderOpenWindowOutput;
  1785.     tellFinderGetWindowInfoOut    tellFinderGetWindowInfoOutput;
  1786.     
  1787.     tellFinderMItemSelectedInput.menuItemID = MItemSelectedID;
  1788.     tellFinderMItemSelectedInput.modifiers = 0;
  1789.     if(GetCtlValue(GetCtlHandleFromID(FinderXDAWindPtr,0x00000901L)) == 0x0001)
  1790.         {
  1791.             tellFinderMItemSelectedInput.flags = 0x8000;
  1792.         }
  1793.     VisWindPtr = findNextVisWindow();     /* We have to bring the Finder window to the front so the menuitems can operate on it */
  1794.     if (VisWindPtr != NIL)
  1795.         {
  1796.             SendRequest (tellFinderGetWindowInfo,0x8001,finderTarget,VisWindPtr,(long)&tellFinderGetWindowInfoOutput);
  1797.             if(((GSString255Ptr)tellFinderGetWindowInfoOutput.windPath) -> length)
  1798.                 {
  1799.                     SendRequest (tellFinderOpenWindow,0x8001,finderTarget,tellFinderGetWindowInfoOutput.windPath,(long)&tellFinderOpenWindowOutput);
  1800.                 }
  1801.         }
  1802.     SendRequest (tellFinderMItemSelected,0x8001,finderTarget,&tellFinderMItemSelectedInput,(long)&tellFinderMItemSelectedOutput);
  1803.     CheckError(tellFinderMItemSelectedOutput.finderResult,0x0000);
  1804.     sprintf(AlertString,"40/Finder Result = $%x\rError - %s/^OK",
  1805.         tellFinderMItemSelectedOutput.finderResult,
  1806.         ErrorString);
  1807.     AlertWindow (0x0000,NULL,AlertString);
  1808. }    
  1809.  
  1810. tellFinderMatchFileToIconProc ()
  1811. {
  1812.     AlertWindow (0x0000,NULL,"40/tellFinderMatchFileToIcon is not implemented by this tool yet./^OK");
  1813. }
  1814.  
  1815. tellFinderAddBundleProc ()
  1816. {
  1817.     AlertWindow (0x0000,NULL,"40/tellFinderAddBundle is not implemented by this tool yet./^OK");
  1818. }
  1819.  
  1820. tellFinderAboutChangeProc ()
  1821. {
  1822.     tellFinderAboutChangeOut    tellFinderAboutChangeOutput;
  1823.     GSString255                 Pathname;
  1824.     
  1825.     TEGetText (0x0002,(long)&Pathname,110L,0x0000,0L,GetCtlHandleFromID(NIL,401L));
  1826.     if(_toolErr) CheckError(_toolErr,0x0001);
  1827.     else
  1828.         {
  1829.             SendRequest (tellFinderAboutChange,0x8001,finderTarget,(long)&Pathname,(long)&tellFinderAboutChangeOutput);
  1830.             CheckError(tellFinderAboutChangeOutput.finderResult,0);
  1831.             sprintf(AlertString,"40/Request Code = tellFinderAboutChange\rFinder Result = $%x\rError - %s/^OK",
  1832.                 tellFinderAboutChangeOutput.finderResult,
  1833.                 ErrorString);
  1834.             AlertWindow (0x0000,NULL,AlertString);
  1835.         }
  1836. }
  1837.  
  1838. tellFinderCheckDatabaseProc ()
  1839. {
  1840.     AlertWindow (0x0000,NULL,"40/tellFinderCheckDatabase is not implemented by this tool yet./^OK");
  1841. }
  1842.  
  1843. tellFinderColorSelectionProc()
  1844. {
  1845.     tellFinderColorSelectionOut    tellFinderColorSelectionOutput;
  1846.     char                         ColorValueString[8];
  1847.     long                        iconColorValue;
  1848.     
  1849.     TEGetText (0x0001,ColorValueString,10L,0x0000,0L,GetCtlHandleFromID(NIL,501L));
  1850.     if(_toolErr) CheckError(_toolErr,0x0001);
  1851.     else
  1852.         {
  1853.             if (strlen(ColorValueString) < 8)
  1854.                 {
  1855.                     AlertWindow (0x0000,NULL,"30/Too few characters in string./^OK");
  1856.                 }
  1857.             else
  1858.                 {
  1859.                     iconColorValue = Hex2Long(ColorValueString,8);
  1860.                     if(_toolErr) CheckError(_toolErr,0x0001);
  1861.                     else
  1862.                         {
  1863.                             SendRequest (tellFinderColorSelection,0x8001,finderTarget,iconColorValue,(long)&tellFinderColorSelectionOutput);
  1864.                             if(tellFinderColorSelectionOutput.finderResult != 0x0000)
  1865.                                 {
  1866.                                     CheckError(tellFinderColorSelectionOutput.finderResult,0x0000);
  1867.                                     sprintf(AlertString,"30/Finder Result = $%x\r%s\rError - %s/^OK",
  1868.                                         tellFinderColorSelectionOutput.finderResult,
  1869.                                         ErrorString);
  1870.                                     AlertWindow (0x0000,NULL,AlertString);
  1871.                                 }
  1872.                         }
  1873.                 }
  1874.         }
  1875. }
  1876.  
  1877. tellFinderAddToExtrasProc ()
  1878. {
  1879.     tellFinderAddToExtrasOut    tellFinderAddToExtrasOutput;
  1880.     static char                    *menuItemTitle[MAXNUMMENUITEMS] =     {
  1881.                                                                     "\pFinderXDA ID $xxxx","\pFinderXDA ID $xxxx","\pFinderXDA ID $xxxx","\pFinderXDA ID $xxxx",
  1882.                                                                     "\pFinderXDA ID $xxxx","\pFinderXDA ID $xxxx","\pFinderXDA ID $xxxx","\pFinderXDA ID $xxxx",
  1883.                                                                     "\pFinderXDA ID $xxxx","\pFinderXDA ID $xxxx","\pFinderXDA ID $xxxx","\pFinderXDA ID $xxxx",
  1884.                                                                     "\pFinderXDA ID $xxxx","\pFinderXDA ID $xxxx","\pFinderXDA ID $xxxx","\pFinderXDA ID $xxxx"
  1885.                                                                     };
  1886.     
  1887.         
  1888.     if (menuItemIndex < MAXNUMMENUITEMS)
  1889.         {            
  1890.             if (menuItemIndex == 0)
  1891.                 {
  1892.                     tellFinderAddToExtrasMenuItem.version = 0x8000;
  1893.                 }
  1894.             else
  1895.                 {
  1896.                     tellFinderAddToExtrasMenuItem.version = 0x0000;
  1897.                 }
  1898.             SendRequest (tellFinderAddToExtras,0x8001,finderTarget,(long)&tellFinderAddToExtrasMenuItem,(long)&tellFinderAddToExtrasOutput);
  1899.             menuItemID[menuItemIndex] = tellFinderAddToExtrasOutput.menuItemID;
  1900.             Int2Hex(menuItemID[menuItemIndex],menuItemTitle[menuItemIndex] + 15,4);
  1901.             if(_toolErr) CheckError(_toolErr,0x0001);
  1902.             else
  1903.                 {
  1904.                     SetMItemName2(0x0000,(long)menuItemTitle[menuItemIndex],menuItemID[menuItemIndex]);
  1905.                     CheckError(tellFinderAddToExtrasOutput.finderResult,0x0000);
  1906.                     sprintf(AlertString,"40/Request Code = tellFinderAddToExtras\rrecvCount = $%x\rResult Code = $%x\rMenuItem ID Added = $%x\tMenu ID = $%x\rError - %s/^OK",
  1907.                         tellFinderAddToExtrasOutput.recvCount,
  1908.                         tellFinderAddToExtrasOutput.finderResult,
  1909.                         menuItemID[menuItemIndex],
  1910.                         tellFinderAddToExtrasOutput.menuID,
  1911.                         ErrorString);
  1912.                     AlertWindow (0x0000,0L,AlertString);
  1913.                     return ++menuItemIndex;
  1914.                 }
  1915.         }
  1916.     else
  1917.         {
  1918.             sprintf(AlertString,"42/You have %d menu items allocated. This is the maximum number that this test tool allows./^OK",
  1919.                 MAXNUMMENUITEMS);
  1920.             AlertWindow (0x0000,0L,AlertString);
  1921.         }
  1922. }
  1923.  
  1924. tellFinderIdleHowLongProc ()
  1925. {
  1926.     tellFinderIdleHowLongOut    tellFinderIdleHowLongOutput;
  1927.     
  1928.     SendRequest (askFinderIdleHowLong,0x8001,finderTarget,0L,(long)&tellFinderIdleHowLongOutput);
  1929.     CheckError(tellFinderIdleHowLongOutput.finderResult,0x0000);
  1930.     sprintf(AlertString,"40/Request Code = tellFinderIdleHowLong\rrecvCount = $%x\rResult Code = $%x\rTick Count = $%lxL\rError - %s/^OK",
  1931.         tellFinderIdleHowLongOutput.recvCount,
  1932.         tellFinderIdleHowLongOutput.finderResult,
  1933.         tellFinderIdleHowLongOutput.tickCount,
  1934.         ErrorString);
  1935.     AlertWindow (0x0000,0L,AlertString);    
  1936. }
  1937.  
  1938. tellFinderGetWindowIconsProc ()
  1939. {
  1940.     tellFinderGetWindowIconsOut        tellFinderGetWindowIconsOutput;
  1941.     GrafPortPtr                        VisWindPtr;
  1942.     CtlRecHndl                        PathnameCtlHandle;
  1943.     Ptr                                PointerAddress;
  1944.     Ptr                                StringAddress;
  1945.     int                                i;
  1946.     char                            ReturnString[16];
  1947.     word                            ButtonSelected;
  1948.     word                            NumIcons;
  1949.     
  1950.     if(GetWindowIconsWindPtr == 0)
  1951.         {
  1952.             VisWindPtr = findNextVisWindow();
  1953.             if(VisWindPtr != NIL)
  1954.                 {
  1955.                     if(GetCtlValue(GetCtlHandleFromID(GetSelectedIconsWindPtr,0x00000903L)) == 0)
  1956.                         {
  1957.                             SendRequest (tellFinderGetWindowIcons,0x8001,finderTarget,VisWindPtr,(long)&tellFinderGetWindowIconsOutput);
  1958.                             sprintf(AlertString,"40/Request Code = tellFinderGetWindowIcons\rrecvCount = $%x\rResult Code = $%x\rStringList Handle = $%lxL\rNumber of Pathnames to follow = $%x/^OK",
  1959.                                 tellFinderGetWindowIconsOutput.recvCount,
  1960.                                 tellFinderGetWindowIconsOutput.finderResult,
  1961.                                 tellFinderGetWindowIconsOutput.stringListHandle,
  1962.                                 **(word **)tellFinderGetWindowIconsOutput.stringListHandle);
  1963.                             AlertWindow (0x0000,0L,AlertString);
  1964.                             if ((**(word **)tellFinderGetWindowIconsOutput.stringListHandle) != 0)
  1965.                                 {
  1966.                                     GetWindowIconsWindPtr = NewWindow (&GetWindowIconsWindParams);
  1967.                                     if(_toolErr) CheckError(_toolErr,0x0001);
  1968.                                     else
  1969.                                         {
  1970.                                             SetUpGetWindowIconsNDASysWindRec();
  1971.                                             SetSysWindow(GetWindowIconsWindPtr);
  1972.                                             GetWindowIconsAuxWindRecPtr = (AuxWindInfoPtr)(GetAuxWindInfo(GetWindowIconsWindPtr));
  1973.                                             GetWindowIconsAuxWindRecPtr -> NDASysWindPtr = (Ptr)&GetWindowIconsNDASysWindRec;
  1974.                                             PathnameCtlHandle = NewControl2(GetWindowIconsWindPtr,0,&MyWindCtl);
  1975.                                             if(_toolErr) CheckError(_toolErr,0x0001);
  1976.                                             else
  1977.                                                 {
  1978.                                                 HLock(tellFinderGetWindowIconsOutput.stringListHandle);
  1979.                                                 PointerAddress = (*tellFinderGetWindowIconsOutput.stringListHandle)+2;
  1980.                                                 for (i = 0; i < **(word **)tellFinderGetWindowIconsOutput.stringListHandle; i++)
  1981.                                                     {
  1982.                                                         TEInsert (0x0002,PointerAddress,0L,0,0L,PathnameCtlHandle);
  1983.                                                         TEInsert (0x0001,"\r\r",0L,0,0L,PathnameCtlHandle);
  1984.                                                         PointerAddress += *(word *)PointerAddress + 2;
  1985.                                                     }
  1986.                                                 (**(TERecordHndl)GetCtlHandleFromID(NIL,0x00001000L)).textFlags |= 0x04000000;
  1987.                                                 DisposeHandle(tellFinderGetWindowIconsOutput.stringListHandle);
  1988.                                                 if(_toolErr) CheckError(_toolErr,0x0001);
  1989.                                                 tellFinderGetSelectedIconsOutput.stringListHandle = NIL;
  1990.                                                 }
  1991.                                         }
  1992.                                 }
  1993.                             }
  1994.                         else
  1995.                             {
  1996.                                 SendRequest (tellFinderGetWindowIcons,0x8001,finderTarget,(long)VisWindPtr|0x80000000,(long)&tellFinderGetWindowIconsOutput);
  1997.                                 NumIcons = **(word **)tellFinderGetWindowIconsOutput.stringListHandle;
  1998.                                 sprintf(AlertString,"40/Request Code = tellFinderGetWindowIcons\rrecvCount = $%x\rResult Code = $%x\rStringList Handle = $%lxL\rNumber of Pathnames to follow = $%x/^OK",
  1999.                                     tellFinderGetWindowIconsOutput.recvCount,
  2000.                                     tellFinderGetWindowIconsOutput.finderResult,
  2001.                                     tellFinderGetWindowIconsOutput.stringListHandle,
  2002.                                     NumIcons);
  2003.                                 AlertWindow (0x0000,0L,AlertString);
  2004.                                 if (NumIcons)
  2005.                                     {
  2006.                                         GetWindowIconsWindPtr = NewWindow (&GetWindowIconsWindParams);
  2007.                                         if(_toolErr) CheckError(_toolErr,0x0001);
  2008.                                         else
  2009.                                             {
  2010.                                                 SetUpGetWindowIconsNDASysWindRec();
  2011.                                                 SetSysWindow(GetWindowIconsWindPtr);
  2012.                                                 GetWindowIconsAuxWindRecPtr = (AuxWindInfoPtr)(GetAuxWindInfo(GetWindowIconsWindPtr));
  2013.                                                 GetWindowIconsAuxWindRecPtr -> NDASysWindPtr = (Ptr)&GetWindowIconsNDASysWindRec;
  2014.                                                 PathnameCtlHandle = NewControl2(GetWindowIconsWindPtr,0,&MyWindCtl);
  2015.                                                 if(_toolErr) CheckError(_toolErr,0x0001);
  2016.                                                 else
  2017.                                                     {
  2018.                                                         HLock((long)tellFinderGetWindowIconsOutput.stringListHandle &~0x80000000);
  2019.                                                         PointerAddress = (*tellFinderGetWindowIconsOutput.stringListHandle)+2;
  2020.                                                         for (i = 0; i < **(word **)tellFinderGetWindowIconsOutput.stringListHandle; i++)
  2021.                                                             {
  2022.                                                                 StringAddress = *(word *)PointerAddress + PointerAddress;
  2023.                                                                 TEInsert (0x0001,"\r",0L,0,0L,PathnameCtlHandle);
  2024.                                                                 TEInsert (0x0002,StringAddress,0L,0,0L,PathnameCtlHandle);
  2025.                                                                 TEInsert (0x0001,"\r",0L,0,0L,PathnameCtlHandle);
  2026.                                                                 PointerAddress += 2;
  2027.                                                                 OutputAWord("\ty coordinate (bottom) of Icon, Icon view - $",&PointerAddress,PathnameCtlHandle);
  2028.                                                                 OutputAWord("\tx coordinate (middle) of Icon, Icon view - $",&PointerAddress,PathnameCtlHandle);
  2029.                                                                 OutputAWord("\ty coordinate of Icon, list view - $",&PointerAddress,PathnameCtlHandle);
  2030.                                                                 OutputAWord("\tHeight of Icon for current view - $",&PointerAddress,PathnameCtlHandle);
  2031.                                                                 OutputAWord("\tWidth of Icon for current view - $",&PointerAddress,PathnameCtlHandle);
  2032.                                                                 PointerAddress = StringAddress + *(word *)StringAddress + 2;
  2033.                                                             }
  2034.                                                         HUnlock((long)tellFinderGetWindowIconsOutput.stringListHandle &~0x80000000);
  2035.                                                         (**(TERecordHndl)GetCtlHandleFromID(NIL,0x00001000L)).textFlags |= 0x04000000;
  2036.                                                         DisposeHandle(tellFinderGetWindowIconsOutput.stringListHandle);
  2037.                                                         if(_toolErr) CheckError(_toolErr,0x0001);
  2038.                                                         tellFinderGetSelectedIconsOutput.stringListHandle = NIL;
  2039.                                                     }
  2040.                                             }
  2041.                                     }
  2042.                             }
  2043.                 }
  2044.             else
  2045.                 {
  2046.                     AlertWindow (0x0000,0L,"33/No open window./^OK");
  2047.                 }
  2048.         }
  2049.     else
  2050.         {
  2051.             ButtonSelected = AlertWindow (0x0000,0L,"42/A tellFinderGetWindowIcons window is already open. Do you want to close it?/^Close Window/Cancel");
  2052.             if (ButtonSelected == 0)
  2053.                 {
  2054.                     CloseIfOpen(&GetWindowIconsWindPtr);
  2055.                 }
  2056.         }
  2057. }
  2058.  
  2059. tellFinderGetWindowInfoProc ()
  2060. {
  2061.     tellFinderGetWindowInfoOut    tellFinderGetWindowInfoOutput;
  2062.     GrafPortPtr                    VisWindPtr;
  2063.     GSString255                 *windPathPtr;
  2064.     char                         WindTitle[128];
  2065.     char                         WindPath[255];
  2066.     unsigned                    EmptyString = 0;
  2067.     
  2068.     VisWindPtr = findNextVisWindow();
  2069.     if(VisWindPtr != NIL)
  2070.         {
  2071.             SendRequest (tellFinderGetWindowInfo,0x8001,finderTarget,findNextVisWindow(),(long)&tellFinderGetWindowInfoOutput);
  2072.             strncpy (WindTitle,tellFinderGetWindowInfoOutput.windTitle,tellFinderGetWindowInfoOutput.windTitle[0] + 1);
  2073.             p2cstr (WindTitle);
  2074.             if (tellFinderGetWindowInfoOutput.windowType & 0x0012)        /* InfoWindID + dirWindID */
  2075.                 {
  2076.                     windPathPtr = (GSString255Ptr)(tellFinderGetWindowInfoOutput.windPath);
  2077.                 }
  2078.             else
  2079.                 {
  2080.                     windPathPtr = (GSString255Ptr)&EmptyString;
  2081.                 }
  2082.             strncpy (WindPath,windPathPtr -> text,windPathPtr -> length);
  2083.             WindPath[windPathPtr -> length] = 0;
  2084.             sprintf(AlertString,"90/Request Code = tellFinderGetWindowInfo\trecvCount = $%x\rResult Code = $%x\tWindow Type = $%x\rWindow View = $%x\tWindow FST = $%x\rWindow Title = %s\rWindow Path = %s/^OK",
  2085.                 tellFinderGetWindowInfoOutput.recvCount,
  2086.                 tellFinderGetWindowInfoOutput.finderResult,
  2087.                 tellFinderGetWindowInfoOutput.windowType,
  2088.                 tellFinderGetWindowInfoOutput.windView,
  2089.                 tellFinderGetWindowInfoOutput.windFST,
  2090.                 WindTitle,
  2091.                 WindPath);
  2092.             AlertWindow (0x0000,0L,AlertString);
  2093.         }
  2094.     else
  2095.         {
  2096.             SendRequest (tellFinderGetWindowInfo,0x8001,finderTarget,findNextVisWindow(),(long)&tellFinderGetWindowInfoOutput);
  2097.             CheckError(tellFinderGetWindowInfoOutput.finderResult,0x0000);
  2098.             sprintf(AlertString,"40/No open window.\rFinder Result = $%x\rError - %s/^OK",
  2099.                 tellFinderGetWindowInfoOutput.finderResult,
  2100.                 ErrorString);
  2101.             AlertWindow (0x0000,0L,AlertString);
  2102.         }
  2103. }
  2104.  
  2105. tellFinderRemoveFromExtrasProc ()
  2106. {
  2107.     tellFinderRemoveFromExtrasOut    tellFinderRemoveFromExtrasOutput;
  2108.     static char                        NoneLeftAlertString[175];
  2109.     
  2110.     if (menuItemIndex > 0 && menuItemIndex <= MAXNUMMENUITEMS)
  2111.         {
  2112.             SendRequest (tellFinderRemoveFromExtras,0x8001,finderTarget,(long)menuItemID[menuItemIndex-1],(long)&tellFinderRemoveFromExtrasOutput);
  2113.             CheckError(tellFinderRemoveFromExtrasOutput.finderResult,0x0000);
  2114.             sprintf(AlertString,"40/Request Code = tellFinderRemoveFromExtras\rrecvCount = $%x\rResult Code = $%x\rMenuItem ID Removed = $%x\rError - %s/^OK",
  2115.                     tellFinderRemoveFromExtrasOutput.recvCount,
  2116.                     tellFinderRemoveFromExtrasOutput.finderResult,
  2117.                     menuItemID[menuItemIndex-1],
  2118.                     ErrorString);
  2119.             AlertWindow (0x0000,0L,AlertString);
  2120.             return --menuItemIndex;
  2121.         }
  2122.     else
  2123.         {
  2124.             sprintf(NoneLeftAlertString,"42/You have deleted all FinderXDA menuItems. This tool will not allow you to delete any other Extras Menu menu items./^OK");
  2125.             AlertWindow (0x0000,0L,NoneLeftAlertString);
  2126.         }
  2127. }
  2128.  
  2129. tellFinderSpecialPreferencesProc ()
  2130. {
  2131.     tellFinderSpecialPreferencesIn    tellFinderSpecialPreferencesInput;
  2132.     tellFinderSpecialPreferencesOut    tellFinderSpecialPreferencesOutput;
  2133.     word                            ButtonSelected;
  2134.     
  2135.     sprintf(AlertString,"40/Choose the way you want to send tellFinderSpecialPreferences./^dragHDtoTrash/Don't dragHDtoTrash");
  2136.     ButtonSelected = AlertWindow (0x0000,0L,AlertString);
  2137.     if (ButtonSelected == 0)
  2138.         {
  2139.             tellFinderSpecialPreferencesInput.dragHDtoTrash = 0x0001;
  2140.             SendRequest (tellFinderSpecialPreferences,0x8001,finderTarget,&tellFinderSpecialPreferencesInput,(long)&tellFinderSpecialPreferencesOutput);
  2141.             CheckError(tellFinderSpecialPreferencesOutput.finderResult,0x0000);
  2142.             sprintf(AlertString,"40/Request Code = tellFinderSpecialPreferences\rrecvCount = $%x\rResult Code = $%x\rError - %s/^OK",
  2143.                     tellFinderSpecialPreferencesOutput.recvCount,
  2144.                     tellFinderSpecialPreferencesOutput.finderResult,
  2145.                     ErrorString);
  2146.             AlertWindow (0x0000,0L,AlertString);
  2147.         }
  2148.     else if (ButtonSelected == 1)
  2149.         {
  2150.             tellFinderSpecialPreferencesInput.dragHDtoTrash = 0x0000;
  2151.             SendRequest (tellFinderSpecialPreferences,0x8001,finderTarget,&tellFinderSpecialPreferencesInput,(long)&tellFinderSpecialPreferencesOutput);
  2152.             CheckError(tellFinderSpecialPreferencesOutput.finderResult,0x0000);
  2153.             sprintf(AlertString,"40/Request Code = tellFinderSpecialPreferences\rrecvCount = $%x\rResult Code = $%x\rError - %s/^OK",
  2154.                     tellFinderSpecialPreferencesOutput.recvCount,
  2155.                     tellFinderSpecialPreferencesOutput.finderResult,
  2156.                     ErrorString);
  2157.             AlertWindow (0x0000,0L,AlertString);
  2158.         }
  2159. }
  2160.  
  2161. HelpWindowProc()
  2162. {
  2163.     if (HelpWindPtr == 0)
  2164.         {
  2165.             HelpWindPtr = NewWindow (&HelpWindParams);
  2166.             if(_toolErr) CheckError(_toolErr,0x0001);
  2167.             else
  2168.                 {
  2169.                     SetUpHelpNDASysWindRec();
  2170.                     SetSysWindow(HelpWindPtr);
  2171.                     HelpAuxWindRecPtr = (AuxWindInfoPtr)(GetAuxWindInfo(HelpWindPtr));
  2172.                     HelpAuxWindRecPtr -> NDASysWindPtr = (Ptr)&HelpNDASysWindRec;
  2173.                     HelpCtlHandle = NewControl2(HelpWindPtr,0x0002,(long)HelpEditTextControlID);
  2174.                     if(_toolErr) CheckError(_toolErr,0x0001);
  2175.                 }
  2176.         }
  2177.     else
  2178.         SelectWindow (HelpWindPtr);
  2179. }
  2180.  
  2181. CloseFromNDA()
  2182. {
  2183.     ResourceShutDown();
  2184.     CloseFinderXDA();
  2185. }
  2186.  
  2187.  
  2188. /* below this point in the program, we must be very careful about
  2189.  * managing the contents of the data bank register.  We must save
  2190.  * it first, alter it to point to the ~globals segment (SaveDB() does this)
  2191.  * and then when we are done, caL RestoreDB().
  2192.  *  Access to arrays and automatic (i.e. local) variables will work correctly
  2193.  * with ANY value of data bank register.
  2194.  */
  2195.  
  2196.  
  2197. /************************************************************************************************/
  2198. /* The DA Close procedure */
  2199.  
  2200. pascal void CloseFinderXDA()
  2201. {
  2202.     int dbr;
  2203.     GrafPortPtr  p;
  2204.     
  2205.     dbr = SaveDB();
  2206.     p  = (GrafPortPtr)GetDeskGlobal(0);
  2207.     if(p == MatchWindPtr)
  2208.         {
  2209.             CloseWindow(MatchWindPtr);
  2210.             MatchWindPtr = 0;
  2211.         }
  2212.     else if(p == HelpWindPtr)
  2213.         {
  2214.             CloseWindow(HelpWindPtr);
  2215.             HelpWindPtr = 0;
  2216.         }
  2217.     else if(p == DebugInfoWindPtr)
  2218.         {
  2219.             CloseWindow(DebugInfoWindPtr);
  2220.             DebugInfoWindPtr = 0;
  2221.         }
  2222.     else if(p == GetSelectedIconsWindPtr)
  2223.         {
  2224.             CloseWindow(GetSelectedIconsWindPtr);
  2225.             GetSelectedIconsWindPtr = 0;
  2226.         }
  2227.     else if(p == GetWindowIconsWindPtr)
  2228.         {
  2229.             CloseWindow(GetWindowIconsWindPtr);
  2230.             GetWindowIconsWindPtr = 0;
  2231.         }
  2232.     else if(p == FinderXDAWindPtr)
  2233.         {
  2234.             DisposeIdleProc();
  2235.             if(tellFinderGetSelectedIconsOutput.stringListHandle != NIL)
  2236.                 {
  2237.                     DisposeHandle((long)tellFinderGetSelectedIconsOutput.stringListHandle & ~0x80000000);
  2238.                     if(_toolErr) CheckError(_toolErr,0x0001);
  2239.                     tellFinderGetSelectedIconsOutput.stringListHandle = NIL;
  2240.                 }
  2241.             CloseIfOpen(&DebugInfoWindPtr);
  2242.             CloseIfOpen(&GetSelectedIconsWindPtr);
  2243.             CloseIfOpen(&GetWindowIconsWindPtr);
  2244.             CloseIfOpen(&HelpWindPtr);
  2245.             CloseWindow(FinderXDAWindPtr);
  2246.             FinderXDAWindPtr = 0;
  2247.             if (TEStarted)
  2248.                 {
  2249.                     TEShutDown();
  2250.                     DisposeHandle(TEZeroPageHndl);
  2251.                     if(_toolErr) CheckError(_toolErr,0x0001);
  2252.                     TEStarted = 0;
  2253.                 }
  2254.             if (FMStarted)
  2255.                 {
  2256.                     FMShutDown();
  2257.                     DisposeHandle(FMZeroPageHndl);
  2258.                     if(_toolErr) CheckError(_toolErr,0x0001);
  2259.                     FMStarted = 0;
  2260.                 }
  2261.             finderSaysIdleFlag = 0;
  2262.             OpenFlag = 0;
  2263.             ResourceShutDown();
  2264.         }        
  2265.     RestoreDB(dbr);
  2266. }
  2267.  
  2268. /************************************************************************************************/
  2269. /* The DA Open procedure */
  2270.  
  2271. pascal GrafPortPtr OpenFinderXDA()
  2272. {
  2273.     GrafPortPtr                 p;
  2274.     int                         dbr;
  2275.     LevelRecGS                    oldSysFileLevel;
  2276.     LevelRecGS                    newSysFileLevel;
  2277.     SysPrefsRecGS                oldSysPrefs;
  2278.     SysPrefsRecGS                newSysPrefs;
  2279.     word                        App_ID;
  2280.     word                        rFile_ID;
  2281.     pointer                        PathNamePtr;
  2282.     tellFinderAreYouThereOut    tellFinderAreYouThereOutput;
  2283.  
  2284.     dbr = SaveDB();
  2285.     OpenFlag = 0;
  2286.     FinderXDAWindPtr = NIL;
  2287.     SendRequest (askFinderAreYouThere,0x8001,finderTarget,0L,&tellFinderAreYouThereOutput);
  2288.     if (_toolErr)
  2289.         {
  2290.         AlertWindow (0x0000,0L,"42/The Finder is not running. The DA window will not be opened./^OK");
  2291.         p = NIL;
  2292.         }
  2293.     else
  2294.         {
  2295.         myID = MMStartUp();
  2296.         LoadOneTool(0x001b,0x0100);            /* Load the Font Manager */
  2297.         if(_toolErr) CheckError(_toolErr,0x0001);
  2298.         else
  2299.             {
  2300.             if ( ! FMStatus() )
  2301.                 {
  2302.                 FMZeroPageHndl = NewHandle(0x100L,myID,0xc005,0L);
  2303.                 if(FMZeroPageHndl == NIL)
  2304.                     {
  2305.                     sprintf(AlertString,"42/NewHandle failed for FMZeroPageHndl./^OK");
  2306.                     AlertWindow (0x0000,NULL,AlertString);
  2307.                     }
  2308.                 else
  2309.                     {
  2310.                     FMStartUp(myID,(Word)*FMZeroPageHndl);
  2311.                     FMStarted = TRUE;
  2312.                     }
  2313.                 }
  2314.             LoadOneTool(0x0022,0x0100);
  2315.             if(_toolErr) CheckError(_toolErr,0x0001);
  2316.             else
  2317.                 {
  2318.                 if ( ! TEStatus() )                                    /* Is TextEdit not started */
  2319.                     {
  2320.                     TEZeroPageHndl = NewHandle(0x100L,myID,0xc005,0L);
  2321.                     if(TEZeroPageHndl == NIL)
  2322.                         {
  2323.                         sprintf(AlertString,"42/NewHandle failed for TEZeroPageHndl./^OK");
  2324.                         AlertWindow (0x0000,NULL,AlertString);
  2325.                         }
  2326.                     else
  2327.                         {
  2328.                         TEStartUp(myID,(Word)*TEZeroPageHndl);        /* Start it */
  2329.                         TEStarted = TRUE;                            /* Set the flag for Close routine */
  2330.                         }
  2331.                     }
  2332.                 App_ID = GetCurResourceApp();    /* Get the current application ID and save */
  2333.                 NDA_ID = MMStartUp();            /* Get the DA ID and save */
  2334.                 ResourceStartUp(NDA_ID);        /* Start the resource manager with DA ID */
  2335.                 PathNamePtr = LGetPathname2(NDA_ID,0x0001);        /* Get the address of the DA pathname */
  2336.                     oldSysFileLevel.pCount = 0x0002;             /* Set-up pBlock for GetLevelGS calll */
  2337.                     oldSysFileLevel.levelMode = 0x0000;
  2338.                 GetLevelGS(&oldSysFileLevel);                    /* Get the current SysFileLevel */
  2339.                     newSysFileLevel.pCount = 0x0002;
  2340.                     newSysFileLevel.level = 0x0080;                /* this protects the resource from being closed */
  2341.                     newSysFileLevel.levelMode = 0x0000;
  2342.                 SetLevelGS(&newSysFileLevel);                    /* Change the file level to protect the resource fork from a close on refernce num 0 */
  2343.                     oldSysPrefs.pCount = 0x0001;
  2344.                 GetSysPrefsGS(&oldSysPrefs);                    /* Get the current SysPrefs */
  2345.                     newSysPrefs.pCount = 0x0001;
  2346.                     newSysPrefs.preferences = (oldSysPrefs.preferences & 0x1fff) | 0x8000;    /* Set new SysPrefs field to new value, will prompt user to insert disk if volume not found */
  2347.                 SetSysPrefsGS(&newSysPrefs);
  2348.                 rFile_ID = OpenResourceFile(0x0001,0L,PathNamePtr);        /* Finally open the DA resource file */
  2349.                 if(_toolErr) CheckError(_toolErr,0x0001);
  2350.                 else                                            /* We go here if no error */
  2351.                     {
  2352.                     SetCurResourceApp(App_ID);                    /* Reset resource app ID back original value */
  2353.                     FinderXDAWindPtr = NewWindow(&FinderXDAWindParams);        /* Create the DA window */
  2354.                     if(_toolErr) CheckError(_toolErr,0x0001);
  2355.                     else
  2356.                         {
  2357.                         SetSysWindow(FinderXDAWindPtr);            /* Set the DA window as the System Window */
  2358.                         OpenFlag = 1;
  2359.                         NewControl2(FinderXDAWindPtr,3,FinderXDACtlList);    /* Create the DA controls */
  2360.                         if(_toolErr) CheckError(_toolErr,0x0001);
  2361.                         }
  2362.                     }
  2363.                 SetSysPrefsGS(&oldSysPrefs);        /* Reset SysPrefs back original value */
  2364.                 SetLevelGS(&oldSysFileLevel);        /* Reset file level back original value */
  2365.                 }
  2366.             }
  2367.         }    
  2368.     quitflag = 0;                                    /* Set the quit flag */
  2369.     p = FinderXDAWindPtr;
  2370.     RestoreDB(dbr);
  2371.     return p;                                       /* WARNING: at this point, DB is at a random value */
  2372. }                                                   /* but access to p wiL work OK; doesn't use DBR */
  2373.  
  2374. /************************************************************************************************/
  2375. /* The DA Action procedure */
  2376.  
  2377. ActionFinderXDA(a_reg, x_reg, y_reg)
  2378.     Word a_reg, x_reg, y_reg;
  2379.     {
  2380.     int dbr;
  2381.     Word theEvent;
  2382.     WmTaskRec myTaskRec;
  2383.     Word MItemSelectedID;
  2384.     int ActionCode;
  2385.     EventRecordPtr EventP;
  2386.  
  2387.     dbr = SaveDB();
  2388.     
  2389.     if(! quitflag) 
  2390.         {
  2391.         ActionCode = a_reg;
  2392.         EventP = (EventRecordPtr) ( ( (Long)y_reg << 16 ) + x_reg );
  2393.         
  2394.         switch(ActionCode) 
  2395.             {
  2396.             case eventAction:
  2397.             
  2398.                 if (EventP->what == wInContent)
  2399.                     AlertWindow(0,NULL,"20|wInContent passed in wmWhat.|^Continue");
  2400.                 myTaskRec.what = EventP->what;
  2401.                 myTaskRec.message = EventP->message;
  2402.                 myTaskRec.where = EventP->where;
  2403.                 myTaskRec.when = EventP->when;
  2404.                 myTaskRec.modifiers = EventP->modifiers;
  2405.                 myTaskRec.wmTaskMask = 0x1fffffL;
  2406.                 theEvent = TaskMasterDA(0,&myTaskRec);
  2407.                 switch(theEvent) 
  2408.                     {
  2409.                     case wInGoAway:
  2410.                         if (myTaskRec.wmTaskData == (long)FinderXDAWindPtr)
  2411.                             {
  2412.                                 quitflag = 1;
  2413.                             }
  2414.                         break;
  2415.                     case wInControl:
  2416.                         if (myTaskRec.wmTaskData == (long)FinderXDAWindPtr)
  2417.                             {
  2418.                             if (myTaskRec.wmTaskData4 == 0x00000100L)
  2419.                                 {
  2420.                                 switch (GetCtlValue(myTaskRec.wmTaskData2))
  2421.                                     {
  2422.                                     case 0x0100:
  2423.                                     AcceptRequests ("\pAppleComputer~FinderXDAHello~",MMStartUp(),HelloRequestProc);    
  2424.                                     break;
  2425.  
  2426.                                     case 0x0101:
  2427.                                     AcceptRequests ("\pAppleComputer~FinderXDAGoodbye~",MMStartUp(),GoodbyeRequestProc);    
  2428.                                     break;
  2429.  
  2430.                                     case 0x0102:
  2431.                                     AcceptRequests ("\pAppleComputer~FinderXDASelectionChanged~",MMStartUp(),SelectionChangedRequestProc);    
  2432.                                     break;
  2433.  
  2434.                                     case 0x0103:
  2435.                                     AcceptRequests ("\pAppleComputer~FinderXDAMItemSelected~",MMStartUp(),MItemSelectedRequestProc);    
  2436.                                     break;
  2437.  
  2438.                                     case 0x0104:
  2439.                                     AcceptRequests ("\pAppleComputer~FinderXDABeforeOpen~",MMStartUp(),BeforeOpenRequestProc);    
  2440.                                     break;
  2441.  
  2442.                                     case 0x0105:
  2443.                                     AcceptRequests ("\pAppleComputer~FinderXDAOpenFailed~",MMStartUp(),OpenFailedRequestProc);    
  2444.                                     break;
  2445.  
  2446.                                     case 0x0106:
  2447.                                     AcceptRequests ("\pAppleComputer~FinderXDABeforeCopy~",MMStartUp(),BeforeCopyRequestProc);    
  2448.                                     break;
  2449.  
  2450.                                     case 0x0107:
  2451.                                     AcceptRequests ("\pAppleComputer~FinderXDAIdle~",MMStartUp(),IdleRequestProc);
  2452.                                     break;
  2453.  
  2454.                                     case 0x0108:
  2455.                                     AcceptRequests ("\pAppleComputer~FinderXDAExtrasChosen~",MMStartUp(),ExtrasChosenRequestProc);    
  2456.                                     break;
  2457.  
  2458.                                     case 0x0109:
  2459.                                     AcceptRequests ("\pAppleComputer~FinderXDABeforeRename~",MMStartUp(),BeforeRenameRequestProc);    
  2460.                                     break;
  2461.  
  2462.                                     case 0x010A:
  2463.                                     AcceptRequests ("\pAppleComputer~FinderXDAKeyHit~",MMStartUp(),KeyHitRequestProc);    
  2464.                                     break;
  2465.  
  2466.                                     case 0x010B:    /* Stop receiving requests */
  2467.                                     RemoveRequestProcs ();
  2468.                                     break;
  2469.                                     }
  2470.                                 }
  2471.                             else if (myTaskRec.wmTaskData4 == 0x00000800L)
  2472.                                 {
  2473.                                 switch (GetCtlValue(myTaskRec.wmTaskData2))
  2474.                                     {
  2475.                                     case 0x8000:
  2476.                                     tellFinderGetDebugInfoProc ();
  2477.                                     break;
  2478.  
  2479.                                     case 0x8001:
  2480.                                     tellFinderAreYouThereProc ();
  2481.                                     break;
  2482.                                     
  2483.                                     case 0x8002:
  2484.                                     tellFinderOpenWindowProc ();
  2485.                                     break;
  2486.  
  2487.                                     case 0x8003:
  2488.                                     tellFinderCloseWindowProc ();
  2489.                                     break;
  2490.  
  2491.                                     case 0x8004:
  2492.                                     tellFinderGetSelectedIconsProc ();
  2493.                                     break;
  2494.  
  2495.                                     case 0x8005:
  2496.                                     tellFinderSetSelectedIconsProc ();
  2497.                                     break;
  2498.  
  2499.                                     case 0x8006:
  2500.                                     tellFinderLaunchThis_Ap_Proc ();
  2501.                                     break;
  2502.  
  2503.                                     case 0x807A:
  2504.                                     tellFinderShutDown_PowerOff_Proc ();
  2505.                                     break;
  2506.  
  2507.                                     case 0x807B:
  2508.                                     tellFinderShutDown_Restart_Proc ();
  2509.                                     break;
  2510.  
  2511.                                     case 0x807C:
  2512.                                     tellFinderShutDown_QuitFinder_Proc ();
  2513.                                     break;
  2514.  
  2515.                                     case 0x800A:
  2516.                                     tellFinderMatchFileToIconProc();
  2517.                                     break;
  2518.  
  2519.                                     case 0x800B:
  2520.                                     tellFinderAddBundleProc ();
  2521.                                     break;
  2522.  
  2523.                                     case 0x800C:
  2524.                                     tellFinderAboutChangeProc ();
  2525.                                     break;
  2526.  
  2527.                                     case 0x800D:
  2528.                                     tellFinderCheckDatabaseProc ();
  2529.                                     break;
  2530.  
  2531.                                     case 0x800F:
  2532.                                     tellFinderAddToExtrasProc ();
  2533.                                     break;
  2534.  
  2535.                                     case 0x8011:
  2536.                                     tellFinderIdleHowLongProc ();
  2537.                                     break;
  2538.  
  2539.                                     case 0x8012:
  2540.                                     tellFinderGetWindowIconsProc ();
  2541.                                     break;
  2542.  
  2543.                                     case 0x8013:
  2544.                                     tellFinderGetWindowInfoProc ();
  2545.                                     break;
  2546.  
  2547.                                     case 0x8014:
  2548.                                     tellFinderRemoveFromExtrasProc ();
  2549.                                     break;
  2550.  
  2551.                                     case 0x8015:
  2552.                                     tellFinderSpecialPreferencesProc ();
  2553.                                     break;
  2554.                                     }
  2555.                                 }
  2556.                             else if (myTaskRec.wmTaskData4 == 0x00000900L)
  2557.                                 {
  2558.                                     MItemSelectedID = GetCtlValue(myTaskRec.wmTaskData2);
  2559.                                     tellFinderMItemSelectedProc(MItemSelectedID);
  2560.                                 }
  2561.                             else if (myTaskRec.wmTaskData4 == 0x0000800EL)
  2562.                                 {
  2563.                                 tellFinderColorSelectionProc();
  2564.                                 }
  2565.                             else if (myTaskRec.wmTaskData4 == 0x00000300L)
  2566.                                 {
  2567.                                 HelpWindowProc();
  2568.                                 }
  2569.                             break;
  2570.                         }
  2571.                         else if (myTaskRec.wmTaskData == (long)MatchWindPtr)
  2572.                             {
  2573.                                 if (myTaskRec.wmTaskData4 == 0x00002000L)
  2574.                                     {
  2575.                                         DoTheMatchProc();
  2576.                                     }
  2577.                             }
  2578.                     break;
  2579.                     }
  2580.                 break;
  2581.             case runAction:
  2582.                 break;
  2583.             case cursorAction:
  2584.                 break;
  2585.             case undoAction:
  2586.                 break;
  2587.             case cutAction:
  2588.                 TECut(NULL);
  2589.                 break;
  2590.             case copyAction:
  2591.                 TECopy(NULL);
  2592.                 break;
  2593.             case pasteAction:
  2594.                 TEPaste(NULL);
  2595.                 break;
  2596.             case clearAction:
  2597.                 TEClear(NULL);
  2598.                 break;
  2599.             default:
  2600.                 break;
  2601.             }
  2602.         if(quitflag)
  2603.             {
  2604.                 DisposeIdleProc();
  2605.                 CloseNDAByWinPtr(FinderXDAWindPtr);
  2606.                 if(_toolErr) CheckError(_toolErr,0x0001);
  2607.             }
  2608.         }
  2609.     RestoreDB(dbr);
  2610.     }
  2611.  
  2612. /************************************************************************************************/
  2613. /* The DA Init procedure */
  2614.  
  2615. InitFinderXDA()
  2616. {
  2617.     unsigned oldDB = SaveDB();
  2618.     menuItemIndex = 0;
  2619.     AcceptRequests ("\pAppleComputer~FinderXDAInitHello~",MMStartUp(),InitHelloRequestProc);    
  2620.     RestoreDB(oldDB);
  2621. }
  2622.  
  2623.